Skip to content

Commit 59b56ae

Browse files
committed
Initial Commit
1 parent b11b5d0 commit 59b56ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1672
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
**/bin
35+
**/obj
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DocuWare.Api.Common.Exceptions
6+
{
7+
public class BadRequestException : Exception
8+
{
9+
public BadRequestException(string message) : base(message)
10+
{
11+
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DocuWare.Api.Common.Exceptions
6+
{
7+
public class ForbiddenException : Exception
8+
{
9+
public ForbiddenException(string message) : base(message)
10+
{
11+
12+
}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DocuWare.Api.Common.Exceptions
6+
{
7+
public class NotFoundException : Exception
8+
{
9+
public NotFoundException(string message) : base(message)
10+
{
11+
12+
}
13+
}
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DocuWare.Api.Models.Common
6+
{
7+
public class DataResult<T>
8+
{
9+
public T[] Data { get; set; }
10+
public int Total { get; set; }
11+
}
12+
13+
public class DataResult
14+
{
15+
public object Data { get; set; }
16+
public int Total { get; set; }
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Text;
5+
6+
namespace DocuWare.Api.Models.Department
7+
{
8+
public class CreateUpdateDepartmentModel
9+
{
10+
public CreateUpdateDepartmentModel()
11+
{
12+
13+
}
14+
15+
[Required]
16+
public String Name { get; set; }
17+
18+
[Required]
19+
public int ParentId { get; set; }
20+
21+
[Required]
22+
public bool Enabled { get; set; }
23+
}
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Text;
5+
6+
namespace DocuWare.Api.Models.Department
7+
{
8+
public class DepartmentModel
9+
{
10+
public DepartmentModel()
11+
{
12+
}
13+
14+
public int Id { get; set; }
15+
public string Name { get; set; }
16+
public int ParentId { get; set; }
17+
18+
public string Hierachy { get; set; }
19+
[DefaultValue(true)]
20+
public bool Enabled { get; set; }
21+
}
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Text;
5+
6+
namespace DocuWare.Api.Models.User
7+
{
8+
public class CreateUpdateUserModel
9+
{
10+
public CreateUpdateUserModel()
11+
{
12+
13+
}
14+
15+
[Required]
16+
public string UserName { get; set; }
17+
18+
[Required]
19+
public string Identification { get; set; }
20+
21+
[Required]
22+
public int DepartmentId { get; set; }
23+
}
24+
}

DocuWare.Api.Models/User/UserModel.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace DocuWare.Api.Models.User
6+
{
7+
public class UserModel
8+
{
9+
public UserModel()
10+
{
11+
12+
}
13+
14+
public int Id { get; set; }
15+
public string UserName { get; set; }
16+
public string Identification { get; set; }
17+
public string DepartmentId { get; set; }
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Microsoft.EntityFrameworkCore.Storage;
5+
6+
namespace DocuWare.Data.Access.DAL
7+
{
8+
public class DbTransaction : ITransaction
9+
{
10+
private readonly IDbContextTransaction _efTransaction;
11+
12+
public DbTransaction(IDbContextTransaction efTransaction)
13+
{
14+
_efTransaction = efTransaction;
15+
}
16+
17+
public void Commit()
18+
{
19+
_efTransaction.Commit();
20+
}
21+
22+
public void Dispose()
23+
{
24+
_efTransaction.Dispose();
25+
}
26+
27+
public void Rollback()
28+
{
29+
_efTransaction.Rollback();
30+
}
31+
}
32+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace DocuWare.Data.Access.DAL
10+
{
11+
public class EFUnitOfWork : IUnitOfWork
12+
{
13+
private DbContext _context;
14+
15+
public EFUnitOfWork(DbContext context)
16+
{
17+
_context = context;
18+
}
19+
20+
public DbContext Context => _context;
21+
22+
public void Add<T>(T obj) where T : class
23+
{
24+
DbSet<T> set = _context.Set<T>();
25+
set.Add(obj);
26+
}
27+
28+
public void Attach<T>(T obj) where T : class
29+
{
30+
DbSet<T> set = _context.Set<T>();
31+
set.Attach(obj);
32+
}
33+
34+
public ITransaction BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Snapshot)
35+
{
36+
return new DbTransaction(_context.Database.BeginTransaction());
37+
}
38+
39+
public void Commit()
40+
{
41+
_context.SaveChanges();
42+
}
43+
44+
public async Task CommitAsync()
45+
{
46+
await _context.SaveChangesAsync();
47+
}
48+
49+
public void Dispose()
50+
{
51+
_context = null;
52+
}
53+
54+
public IQueryable<T> Query<T>() where T : class
55+
{
56+
return _context.Set<T>();
57+
}
58+
59+
public void Remove<T>(T obj) where T : class
60+
{
61+
DbSet<T> set = _context.Set<T>();
62+
set.Remove(obj);
63+
}
64+
65+
public void Update<T>(T obj) where T : class
66+
{
67+
DbSet<T> set = _context.Set<T>();
68+
set.Attach(obj);
69+
_context.Entry(obj).State = EntityState.Modified;
70+
}
71+
}
72+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace DocuWare.Data.Access.DAL
4+
{
5+
public interface ITransaction : IDisposable
6+
{
7+
void Commit();
8+
void Rollback();
9+
}
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace DocuWare.Data.Access.DAL
9+
{
10+
public interface IUnitOfWork : IDisposable
11+
{
12+
ITransaction BeginTransaction(IsolationLevel isolationLevel = IsolationLevel.Snapshot);
13+
14+
void Add<T>(T obj) where T : class;
15+
void Update<T>(T obj) where T : class;
16+
void Remove<T>(T obj) where T : class;
17+
IQueryable<T> Query<T>() where T : class;
18+
void Commit();
19+
Task CommitAsync();
20+
void Attach<T>(T obj) where T : class;
21+
}
22+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using DocuWare.Data.Access.Maps.Common;
2+
using Microsoft.EntityFrameworkCore;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using Microsoft.Extensions.Configuration;
7+
8+
namespace DocuWare.Data.Access.DAL
9+
{
10+
public class MainDbContext : DbContext
11+
{
12+
public MainDbContext(DbContextOptions<MainDbContext> options) : base(options)
13+
{
14+
15+
}
16+
17+
protected override void OnModelCreating(ModelBuilder modelBuilder)
18+
{
19+
IEnumerable<IMap> mappings = MappingsHelper.GetMainMappings();
20+
21+
foreach (IMap mapping in mappings)
22+
{
23+
mapping.Visit(modelBuilder);
24+
}
25+
}
26+
27+
protected override void OnConfiguring(DbContextOptionsBuilder options)
28+
{
29+
options.UseSqlServer("Server=192.168.1.200;Database=docuware;User Id=sa;Password=aaaa;");
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)