예제 #1
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            Jan19Payroll = await Context.Jan19Payroll.FindAsync(id);

            var jan19payroll = await Context
                               .Jan19Payroll.AsNoTracking()
                               .FirstOrDefaultAsync(m => m.EmployeeID == id);

            if (jan19payroll == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, jan19payroll,
                Jan19PayrollOperations.Delete);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            Context.Jan19Payroll.Remove(Jan19Payroll);
            await Context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
예제 #2
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            Jan19Payroll = await Context.Jan19Payroll
                           .Include(j => j.Employee).FirstOrDefaultAsync(m => m.EmployeeID == id);

            if (Jan19Payroll == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, Jan19Payroll,
                Jan19PayrollOperations.Delete);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            return(Page());
        }
예제 #3
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            Jan19Payroll = await Context.Jan19Payroll.Include(j => j.Employee).FirstOrDefaultAsync(m => m.EmployeeID == id);

            if (Jan19Payroll == null)
            {
                return(NotFound());
            }
            ViewData["EmployeeID"] = new SelectList(Context.Employee, "ID", "FullName");
            // return Page();

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, Jan19Payroll,
                Jan19PayrollOperations.Update);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            return(Page());
        }
예제 #4
0
파일: SeedData.cs 프로젝트: shasans/0g-hrms
        public static void SeedDB(ApplicationDbContext context, string adminID2)
        {
            context.Database.EnsureCreated();

            if (context.Employee.Any())
            {
                return;   // DB has been seeded
            }

            var employees = new Employee[]
            {
                new Employee {
                    FirstName = "Suha", LastName = "Hasan", Gender = Gender.Female, Nationality = "Pakistan", DoB = DateTime.Parse("1998-04-10"), Grade = 7, Position = "Developer", MaritalStatus = MaritalStatus.Single, Salary = 2000, Allowance1 = 400, Allowance2 = 0, Allowance3 = 0, HiringDate = DateTime.Parse("2019-09-01"), OwnerID = adminID2
                }
            };

            foreach (Employee e in employees)
            {
                context.Employee.Add(e);
            }
            context.SaveChanges();

            var clients = new Client[]
            {
                new Client {
                    Project = "SABRA.AE", Name = "Islam Al Khalifa", Address = "*****@*****.**", Mobile = "+971503374373", Company = "Sabra Tourism & Travel LLC", Country = "United Arab Emirates"
                }
            };

            foreach (Client cl in clients)
            {
                context.Client.Add(cl);
            }
            context.SaveChanges();

            var vendors = new Vendor[]
            {
                new Vendor {
                    Name = "Planet01", Address = "*****@*****.**", Mobile = "+92-2136942939, +92-3452201069", Company = "Planet 01", Country = "Pakistan", BankName = "Faysal Bank", IBAN = "0119007000006436", BankCountry = "Pakistan"
                }
            };

            foreach (Vendor ve in vendors)
            {
                context.Vendor.Add(ve);
            }
            context.SaveChanges();

            var invoiceitems = new InvoiceItem[]
            {
                new InvoiceItem {
                    Date = "Hosting Unlimited Storage, Unlimited Emails Accounts", Hours = 1, Price = 1000.0
                },
                new InvoiceItem {
                    Date = "Web Security Shield and SSL Certificate", Hours = 1, Price = 1050.0
                },
                new InvoiceItem {
                    Date = "Website Transfer and 30 Emails Setup Fees", Hours = 1, Price = 1200.0
                },
                new InvoiceItem {
                    Date = "Free Domain Name", Hours = 1, Price = 0.0
                }
            };

            foreach (InvoiceItem ii in invoiceitems)
            {
                context.InvoiceItem.Add(ii);
            }
            context.SaveChanges();

            /* var jan19payrolls = new Jan19Payroll[]
             * {
             * new Jan19Payroll{EmployeeID=employees.Single( e => e.LastName == "Hasan").ID, Deduction=0, OvertimeHours=0, Bonus=0, OwnerID=adminID2}
             * };
             * foreach (Jan19Payroll j in jan19payrolls)
             * {
             *   context.Jan19Payroll.Add(j);
             * }
             * context.SaveChanges(); */

            var jan19payrolls = new Jan19Payroll[]
            {
                new Jan19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jan19Payroll j in jan19payrolls)
            {
                context.Jan19Payroll.Add(j);
            }
            context.SaveChanges();

            var jan20payrolls = new Jan20Payroll[]
            {
                new Jan20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jan20Payroll jj in jan20payrolls)
            {
                context.Jan20Payroll.Add(jj);
            }
            context.SaveChanges();

            var feb19payrolls = new Feb19Payroll[]
            {
                new Feb19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Feb19Payroll f in feb19payrolls)
            {
                context.Feb19Payroll.Add(f);
            }
            context.SaveChanges();

            var feb20payrolls = new Feb20Payroll[]
            {
                new Feb20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Feb20Payroll ff in feb20payrolls)
            {
                context.Feb20Payroll.Add(ff);
            }
            context.SaveChanges();

            var mar19payrolls = new Mar19Payroll[]
            {
                new Mar19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Mar19Payroll m in mar19payrolls)
            {
                context.Mar19Payroll.Add(m);
            }
            context.SaveChanges();

            var mar20payrolls = new Mar20Payroll[]
            {
                new Mar20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Mar20Payroll mm in mar20payrolls)
            {
                context.Mar20Payroll.Add(mm);
            }
            context.SaveChanges();

            var apr19payrolls = new Apr19Payroll[]
            {
                new Apr19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Apr19Payroll a in apr19payrolls)
            {
                context.Apr19Payroll.Add(a);
            }
            context.SaveChanges();

            var apr20payrolls = new Apr20Payroll[]
            {
                new Apr20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Apr20Payroll aa in apr20payrolls)
            {
                context.Apr20Payroll.Add(aa);
            }
            context.SaveChanges();

            var may19payrolls = new May19Payroll[]
            {
                new May19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (May19Payroll y in may19payrolls)
            {
                context.May19Payroll.Add(y);
            }
            context.SaveChanges();

            var may20payrolls = new May20Payroll[]
            {
                new May20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (May20Payroll yy in may20payrolls)
            {
                context.May20Payroll.Add(yy);
            }
            context.SaveChanges();

            var jun19payrolls = new Jun19Payroll[]
            {
                new Jun19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jun19Payroll u in jun19payrolls)
            {
                context.Jun19Payroll.Add(u);
            }
            context.SaveChanges();

            var jun20payrolls = new Jun20Payroll[]
            {
                new Jun20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jun20Payroll uu in jun20payrolls)
            {
                context.Jun20Payroll.Add(uu);
            }
            context.SaveChanges();

            var jul19payrolls = new Jul19Payroll[]
            {
                new Jul19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jul19Payroll l in jul19payrolls)
            {
                context.Jul19Payroll.Add(l);
            }
            context.SaveChanges();

            var jul20payrolls = new Jul20Payroll[]
            {
                new Jul20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Jul20Payroll ll in jul20payrolls)
            {
                context.Jul20Payroll.Add(ll);
            }
            context.SaveChanges();

            var aug19payrolls = new Aug19Payroll[]
            {
                new Aug19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Aug19Payroll g in aug19payrolls)
            {
                context.Aug19Payroll.Add(g);
            }
            context.SaveChanges();

            var aug20payrolls = new Aug20Payroll[]
            {
                new Aug20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Aug20Payroll gg in aug20payrolls)
            {
                context.Aug20Payroll.Add(gg);
            }
            context.SaveChanges();

            var sep19payrolls = new Sep19Payroll[]
            {
                new Sep19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Sep19Payroll p in sep19payrolls)
            {
                context.Sep19Payroll.Add(p);
            }
            context.SaveChanges();

            var sep20payrolls = new Sep20Payroll[]
            {
                new Sep20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Sep20Payroll pp in sep20payrolls)
            {
                context.Sep20Payroll.Add(pp);
            }
            context.SaveChanges();

            var oct19payrolls = new Oct19Payroll[]
            {
                new Oct19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Oct19Payroll o in oct19payrolls)
            {
                context.Oct19Payroll.Add(o);
            }
            context.SaveChanges();

            var oct20payrolls = new Oct20Payroll[]
            {
                new Oct20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Oct20Payroll oo in oct20payrolls)
            {
                context.Oct20Payroll.Add(oo);
            }
            context.SaveChanges();

            var nov19payrolls = new Nov19Payroll[]
            {
                new Nov19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Nov19Payroll n in nov19payrolls)
            {
                context.Nov19Payroll.Add(n);
            }
            context.SaveChanges();

            var nov20payrolls = new Nov20Payroll[]
            {
                new Nov20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Nov20Payroll nn in nov20payrolls)
            {
                context.Nov20Payroll.Add(nn);
            }
            context.SaveChanges();

            var dec19payrolls = new Dec19Payroll[]
            {
                new Dec19Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Dec19Payroll d in dec19payrolls)
            {
                context.Dec19Payroll.Add(d);
            }
            context.SaveChanges();

            var dec20payrolls = new Dec20Payroll[]
            {
                new Dec20Payroll {
                    Total = 0, OwnerID = adminID2
                }
            };

            foreach (Dec20Payroll dd in dec20payrolls)
            {
                context.Dec20Payroll.Add(dd);
            }
            context.SaveChanges();

            var receiptinvoices = new ReceiptInvoice[]
            {
                new ReceiptInvoice {
                    PaymentType = "Expense", Amount = 0
                },
                new ReceiptInvoice {
                    PaymentType = "Contract", Amount = 0
                }
            };

            foreach (ReceiptInvoice rr in receiptinvoices)
            {
                context.ReceiptInvoice.Add(rr);
            }
            context.SaveChanges();

            var paymentinvoices = new PaymentInvoice[]
            {
                new PaymentInvoice {
                    Amount = 0
                }
            };

            foreach (PaymentInvoice rr in paymentinvoices)
            {
                context.PaymentInvoice.Add(rr);
            }
            context.SaveChanges();


            /* var paymentinvoices = new PaymentInvoice[]
             * {
             * new PaymentInvoice{RecieverType= "Client", ClientID = 1, BankAccount="123", Amount=2000, ImageName="completion certificate_6036.pdf", OwnerID=adminID2}
             * };
             * foreach (PaymentInvoice v in paymentinvoices)
             * {
             *   context.PaymentInvoice.Add(v);
             * }
             * context.SaveChanges();*/
        }