Beispiel #1
0
 public static void UpdateClaim(Claim claim)
 {
     using (FinanceDBContext db = new FinanceDBContext())
     {
         try
         {
             Claim oldClaim = db.Claims.SingleOrDefault(c => c.ClaimId == claim.ClaimId);
             if (oldClaim != null)
             {
                 oldClaim.ClaimantLiable = claim.ClaimantLiable;
                 oldClaim.ClaimDate      = claim.ClaimDate;
                 oldClaim.EmployeeId     = claim.EmployeeId;
                 oldClaim.ReferenceNum   = claim.ReferenceNum;
                 oldClaim.RequestType    = claim.RequestType;
                 oldClaim.StatusDate     = claim.StatusDate;
                 oldClaim.WorkLocation   = claim.WorkLocation;
                 UpdateEmployee(claim.Employee);
                 db.SaveChanges();
             }
             else
             {
                 InsertEmployee(claim.Employee);
                 InsertClaim(claim);
             }
         } catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
Beispiel #2
0
 public List <User> GetAll()
 {
     using (FinanceDBContext _context = new FinanceDBContext())
     {
         return(_context.User.ToList <User>());
     }
 }
Beispiel #3
0
 public User Authenticate(string UserName, string Password)
 {
     using (FinanceDBContext _context = new FinanceDBContext())
     {
         return(_context.User.FirstOrDefault(x => x.Password.Trim() == Password && x.UserName == UserName));
     }
 }
Beispiel #4
0
        public static List <Center> GetCenters()
        {
            List <Center> centers = new List <Center>();

            using (var db = new FinanceDBContext())
            {
                centers.AddRange(db.Centers.ToList());
            }

            return(centers);
        }
Beispiel #5
0
        public static void UpdatePayment(Payment payment)
        {
            using (FinanceDBContext db = new FinanceDBContext())
            {
                Payment oldPayment = db.Payments.SingleOrDefault(p => p.PaymentId == payment.PaymentId);

                if (oldPayment != null)
                {
                    oldPayment.PaymentId  = payment.PaymentId;
                    oldPayment.ClaimId    = payment.ClaimId;
                    oldPayment.DueDate    = payment.DueDate;
                    oldPayment.Quarter    = payment.Quarter;
                    oldPayment.AmountPaid = payment.AmountPaid;
                }
            }
        }
Beispiel #6
0
        public static List <Payment> GetPayments()
        {
            List <Payment> payments = new List <Payment>();

            using (FinanceDBContext db = new FinanceDBContext())
            {
                try
                {
                    payments = db.Payments.Include("Claim.Employee").ToList();
                } catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(payments);
        }
Beispiel #7
0
        public static List <Employee> GetEmployees()
        {
            List <Employee> employees = new List <Employee>();

            using (FinanceDBContext db = new FinanceDBContext())
            {
                try
                {
                    employees = db.Employees.Include("Center").ToList();
                } catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(employees);
        }
Beispiel #8
0
        public static List <Claim> GetClaims()
        {
            List <Claim> claims = new List <Claim>();

            using (FinanceDBContext db = new FinanceDBContext())
            {
                try
                {
                    claims = db.Claims.Include("Employee").ToList();
                } catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(claims);
        }
Beispiel #9
0
        public static bool InsertEmployee(Employee employee)
        {
            bool result = false;

            using (var db = new FinanceDBContext())
            {
                employee.Center = null;
                db.Employees.Add(employee);
                int numRows = db.SaveChanges();

                if (numRows > 0)
                {
                    result = true;
                }
            }

            return(result);
        }
Beispiel #10
0
        public static bool InsertClaim(Claim claim)
        {
            bool result = false;

            using (var db = new FinanceDBContext())
            {
                claim.EmployeeId = claim.Employee.EmployeeId;
                claim.Employee   = null;
                db.Claims.Add(claim);
                int numRows = db.SaveChanges();
                if (numRows > 0)
                {
                    result = true;
                }
            }

            return(result);
        }
Beispiel #11
0
        public static bool Insert <T>(T item) where T : class
        {
            bool result = false;

            using (FinanceDBContext context = new FinanceDBContext())
            {
                try
                {
                    context.Set <T>().Add(item);
                    int numRows = context.SaveChanges();
                    result = numRows > 0 ? true : false;
                } catch (Exception ex)
                {
                    result = false;
                    Console.WriteLine(ex.Message);
                }
            }

            return(result);
        }
Beispiel #12
0
 public static void UpdateEmployee(Employee employee)
 {
     using (FinanceDBContext db = new FinanceDBContext())
     {
         try
         {
             Employee oldEmployee = db.Employees.SingleOrDefault(e => e.EmployeeId == employee.EmployeeId);
             if (oldEmployee != null)
             {
                 oldEmployee.EmployeeId = employee.EmployeeId;
                 oldEmployee.CenterId   = employee.CenterId;
                 oldEmployee.FirstName  = employee.FirstName;
                 oldEmployee.LastName   = employee.LastName;
                 oldEmployee.SSN        = employee.SSN;
                 db.SaveChanges();
             }
         } catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
Beispiel #13
0
        public bool CreateUser(UserVM userVM)
        {
            using (FinanceDBContext _context = new FinanceDBContext())
            {
                User newUser = new User
                {
                    Email        = userVM.Email,
                    FirstName    = userVM.FirstName,
                    LastName     = userVM.LastName,
                    Id           = 0,
                    Password     = userVM.Password,
                    PhoneNo      = userVM.PhoneNo,
                    CreatedDate  = DateTime.Now,
                    IsDeleted    = false,
                    ModifiedDate = DateTime.Now,
                    UserName     = userVM.Email
                };

                _context.User.Add(newUser);
                _context.SaveChanges();
                return(true);
            }
        }
Beispiel #14
0
 public AppUserRepository(FinanceDBContext dbContext, IUserAccesor userAccessor)
 {
     _userAccessor = userAccessor;
     _dbSet        = dbContext.Set <AppUser>();
 }
 public TransactionTypeRepository(FinanceDBContext dbContext) : base(dbContext)
 {
     _dbSet = dbContext.Set <TransactionType>();
 }
 public CashFlowController(FinanceDBContext context)
 {
     _context = context;
 }
Beispiel #17
0
 public RepeatTransactionsController(FinanceDBContext context)
 {
     _context = context;
 }
Beispiel #18
0
 public BankTransactionRepository(FinanceDBContext dbContext) : base(dbContext)
 {
     _dbSet = dbContext.Set <BankTransaction>();
 }
Beispiel #19
0
 public DBDataOperation()
 {
     db = new FinanceDBContext();
 }
Beispiel #20
0
 public BaseRepository(FinanceDBContext context)
 {
     _context = context;
     _dbSet   = context.Set <TEntity>();
 }
Beispiel #21
0
        public static async Task SeedData(FinanceDBContext context, UserManager <AppUser> userManager)
        {
            var userId = Guid.NewGuid().ToString();

            if (!userManager.Users.Any())
            {
                var users = new List <AppUser>
                {
                    new AppUser {
                        Id = userId, DisplayName = "Vlad", UserName = "******", Email = "*****@*****.**"
                    },
                    new AppUser {
                        DisplayName = "Tom", UserName = "******", Email = "*****@*****.**"
                    },
                    new AppUser {
                        DisplayName = "Jane", UserName = "******", Email = "*****@*****.**"
                    }
                };

                foreach (var user in users)
                {
                    await userManager.CreateAsync(user, "Pa$$word1");
                }
            }

            if (context.Transaction.Any())
            {
                return;
            }

            var transactions = new List <Transaction>
            {
                new Transaction
                {
                    Money             = 7001,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7002,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7003,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7004,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7005,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7006,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7007,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7008,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7009,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7010,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                },
                new Transaction
                {
                    Money             = 7011,
                    TransactionStatus = false,
                    TransactionType   = new TransactionType
                    {
                        Id = Guid.NewGuid(),
                        TransactionTypes = "type1"
                    },
                    AppUserId = userId
                }
            };

            var transactionTypes = new List <TransactionType>
            {
                new TransactionType
                {
                    Id = Guid.NewGuid(),
                    TransactionTypes = "type1"
                },
                new TransactionType
                {
                    Id = Guid.NewGuid(),
                    TransactionTypes = "type2"
                },
                new TransactionType
                {
                    Id = Guid.NewGuid(),
                    TransactionTypes = "type3"
                },
                new TransactionType
                {
                    Id = Guid.NewGuid(),
                    TransactionTypes = "type4"
                },
                new TransactionType
                {
                    Id = Guid.NewGuid(),
                    TransactionTypes = "type5"
                }
            };

            var banks = new List <Bank>
            {
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank1"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank2"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank3"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank4"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank5"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank6"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank7"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank8"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank9"
                },
                new Bank
                {
                    Id   = Guid.NewGuid(),
                    Name = "bank10"
                }
            };


            var description = new List <UserDescription>
            {
                new UserDescription
                {
                    UserDescriptionId = userId,
                    Description       =
                        @"In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available. It is also used to temporarily replace text in a process called greeking, which allows designers to consider the form of a webpage or publication, without the meaning of the text influencing the design.
"
                }
            };

            await context.Banks.AddRangeAsync(banks);

            await context.UserDescriptions.AddRangeAsync(description);

            await context.Transaction.AddRangeAsync(transactions);

            await context.TransactionType.AddRangeAsync(transactionTypes);

            await context.SaveChangesAsync();
        }
 public FinanceRepository(FinanceDBContext ctx)
 {
     _ctx = ctx;
 }