public ActionResult Index() { var Db = new ApricotContext(); var departments = Db.Departments; return(View(departments)); }
public ActionResult Edit(Int64 id) { var Db = new ApricotContext(); var dept = Db.Departments.First(d => d.Dept_ID == id); return(View(dept)); }
public List <FullEmployee> GetAllFullEmployee() { var Db = new ApricotContext(); List <FullEmployee> myfullemployees = new List <FullEmployee>(0); EmployeeRepository employeeRepo = new EmployeeRepository(Db); EmployeeDetailRepository employeeDetailRepo = new EmployeeDetailRepository(Db); List <Employee> employees = employeeRepo.GetAll().ToList(); foreach (var employee in employees) { Employee_Detail employeeDetail = employeeDetailRepo.GetByEmpID(employee.Emp_ID); FullEmployee fullemp = new FullEmployee(); if (employeeDetail != null) { fullemp.Emp_ID = employee.Emp_ID; fullemp.Emp_Name = employee.Emp_Name; fullemp.Emp_No = employee.Emp_No; fullemp.Department = _context.Departments.Find(employee.Dept_ID); fullemp.Is_Active = employee.Is_Active; fullemp.Emp_Address = employeeDetail.Emp_Address; fullemp.Emp_Contact_No = employeeDetail.Emp_Contact_No; fullemp.Emp_Gender = employeeDetail.Emp_Gender; } myfullemployees.Add(fullemp); } return(myfullemployees); }
public ActionResult Create(BillViewModel model) { if (ModelState.IsValid) { var Db = new ApricotContext(); FillBillsViewModel fbvm = new FillBillsViewModel(Db); fbvm.CreateNewBill(User.Identity.Name, model); //Get BillID BillDetailRepository billdetailrepo = new BillDetailRepository(Db); var billdetail = billdetailrepo.GetAll().Where(bd => (bd.Bill_Date == model.BillDate && bd.Bill_Type == model.BillType && bd.Bill_ModeOfPayment == model.ModeOfPayment)); model.BillID = billdetail.Select(bd => bd.Bill_ID).Single(); //Create Notification for New Bill NotificationBL notibl = new NotificationBL(Db); notibl.NotifyManager(model.BillID); return(RedirectToAction("Index")); } //Something Went wrong, redisplay form return(View(model)); }
public FullEmployee GetFullEmployeeByEmpNumber(Int64 id) { var Db = new ApricotContext(); FullEmployee fullEmployee = new FullEmployee(); EmployeeRepository employeeRepo = new EmployeeRepository(Db); EmployeeDetailRepository employeeDetailRepo = new EmployeeDetailRepository(Db); DepartmentRepository departmentRepo = new DepartmentRepository(Db); Employee employee = employeeRepo.GetByEmpID(id); Employee_Detail employeeDetail = employeeDetailRepo.GetByEmpID(id); Department department = departmentRepo.GetByDepartmentID(employee.Dept_ID); if (employee != null && employeeDetail != null) { fullEmployee.Emp_ID = employee.Emp_ID; fullEmployee.Emp_No = employee.Emp_No; fullEmployee.Emp_Name = employee.Emp_Name; fullEmployee.Is_Active = employee.Is_Active; fullEmployee.Department = _context.Departments.Find(employee.Dept_ID); fullEmployee.Emp_Address = employeeDetail.Emp_Address; fullEmployee.Emp_Contact_No = employeeDetail.Emp_Contact_No; fullEmployee.Emp_Gender = employeeDetail.Emp_Gender; } return(fullEmployee); }
// Enable initialization with an instance of ApplicationUser: public SelectUserRolesViewModel(ApplicationUser user) : this() { this.UserName = user.UserName; this.FirstName = user.FirstName; this.LastName = user.LastName; var Db = new ApricotContext(); // Add all available roles to the list of EditorViewModels: var allRoles = Db.Roles; foreach (var role in allRoles) { // An EditorViewModel will be used by Editor Template: var rvm = new SelectRoleEditorViewModel(role); this.Roles.Add(rvm); } // Set the Selected property to true for those roles for // which the current user is a member: var rm = new RoleManager <IdentityRole>( new RoleStore <IdentityRole>(new ApricotContext())); foreach (var userRole in user.Roles) { var checkUserRole = this.Roles.Find(r => r.RoleName == rm.FindById(userRole.RoleId).Name); checkUserRole.Selected = true; } }
public ActionResult ConfirmDecision(String decision, String Department, Int64 id) { ApricotContext Db = new ApricotContext(); BillRepository billrepo = new BillRepository(Db); Bill bill = billrepo.GetByBillID(id); if (decision == "yes") { bill.Bill_Status = Data.Models.ApricotEnums.BillSatusEnum.APPROVED; billrepo.UpdateBill(bill); FinanceManagerBL fmbl = new FinanceManagerBL(Db); fmbl.AlloteFinanceManager(id, Department); NotificationBL notibl = new NotificationBL(Db); notibl.NotificationOfApproval(id); } else if (decision == "no") { bill.Bill_Status = Data.Models.ApricotEnums.BillSatusEnum.REJECTED; billrepo.UpdateBill(bill); NotificationBL notibl = new NotificationBL(Db); notibl.NotificationOfRejection(bill.Bill_ID); } return(RedirectToAction("Index", "Manager")); }
// // GET: /Manager/ public ActionResult Index() { var Db = new ApricotContext(); FillBillsViewModel gbvm = new FillBillsViewModel(Db); var Managerbills = gbvm.getManagerBills(User.Identity.Name).OrderByDescending(bil => bil.BillDate); return(View(Managerbills)); }
/// <summary> /// Constructor of DepartmentRepository /// </summary> /// <param name="context">Accepts Context of the Application</param> public DepartmentRepository(ApricotContext context) { if (context == null) { throw new ArgumentNullException(); } _context = context; }
// // GET: /ManageEmployee/ public ActionResult Index() { var Db = new ApricotContext(); FillFullEmployee gfemp = new FillFullEmployee(Db); var fullemployees = gfemp.GetAllFullEmployee(); return(View(fullemployees)); }
/// <summary> /// Constructor Of Bill Repository /// </summary> /// <param name="context">Context</param> /// <exception cref="">ArgumentNullException</exception> public BillRepository(ApricotContext context) { if (context == null) { throw new ArgumentNullException("context"); } _context = context; }
public ActionResult Details(Int64 id) { ApricotContext Db = new ApricotContext(); FillBillsViewModel fbvm = new FillBillsViewModel(Db); BillViewModel bvm = fbvm.getBillDetail(id); return(View(bvm)); }
/// <summary> /// Constructor of Notification Repository /// </summary> /// <param name="context">Accepts Context of the Applicayion</param> public NotificationRepository(ApricotContext context) { if (context == null) { throw new ArgumentNullException(); } _context = context; }
public ActionResult UserRoles(string id) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == id); var model = new SelectUserRolesViewModel(user); return(View(model)); }
public ActionResult DeleteConfirmed(string id) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == id); Db.Users.Remove(user); Db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(string id, ManageMessageId?Message = null) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == id); var model = new EditUserViewModel(user); ViewBag.MessageId = Message; return(View(model)); }
public ActionResult Notifications() { ApricotContext Db = new ApricotContext(); NotificationRepository notirepo = new NotificationRepository(Db); var emp_Id = Db.Employees.Where(e => e.Emp_No == User.Identity.Name).Select(e => e.Emp_ID).Single(); var notifications = notirepo.GetAllByEmpID(emp_Id).OrderByDescending(ntf => ntf.TimeStamp); return(View(notifications)); }
public ActionResult Delete(string id = null) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == id); var model = new EditUserViewModel(user); if (user == null) { return(HttpNotFound()); } return(View(model)); }
public ActionResult Create(FullEmployee model) { if (ModelState.IsValid) { var Db = new ApricotContext(); FillFullEmployee Fillfemp = new FillFullEmployee(Db); Fillfemp.CreateFullEmployee(model); return(RedirectToAction("index")); } return(View(model)); }
public ActionResult Details(Int64 id) { ApricotContext Db = new ApricotContext(); FillBillsViewModel fbvm = new FillBillsViewModel(Db); BillViewModel bvm = fbvm.getBillDetail(id); var departments = Db.Departments.Select(d => d.Dept_Name).ToList(); ViewBag.departmentslist = departments; return(View(bvm)); }
public ActionResult Create(Department model) { if (ModelState.IsValid) { var Db = new ApricotContext(); DepartmentRepository repo = new DepartmentRepository(Db); repo.AddDepartment(model); return(RedirectToAction("Index")); } //Something Went wrong, redisplay form return(View(model)); }
public ActionResult Index() { var Db = new ApricotContext(); var users = Db.Users; var model = new List <EditUserViewModel>(); foreach (var user in users) { var u = new EditUserViewModel(user); model.Add(u); } return(View(model)); }
public ActionResult Edit(FullEmployee model) { if (ModelState.IsValid) { var Db = new ApricotContext(); FillFullEmployee Fillfemp = new FillFullEmployee(Db); Fillfemp.EditFullEmployee(model); return(RedirectToAction("Index", "ManageEmployee")); } return(View(model)); }
public async Task <ActionResult> Edit(EditUserViewModel model) { if (ModelState.IsValid) { var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == model.UserName); // Update the user data: user.FirstName = model.FirstName; user.LastName = model.LastName; user.Email = model.Email; Db.Entry(user).State = System.Data.Entity.EntityState.Modified; await Db.SaveChangesAsync(); return(RedirectToAction("Index")); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Edit(Department model) { if (ModelState.IsValid) { var Db = new ApricotContext(); var department = Db.Departments.First(dept => dept.Dept_ID == model.Dept_ID); // Update the dept data: department.Dept_Name = model.Dept_Name; Db.Entry(department).State = System.Data.Entity.EntityState.Modified; Db.SaveChanges(); return(RedirectToAction("Index")); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult UserRoles(SelectUserRolesViewModel model) { if (ModelState.IsValid) { var idManager = new IdentityManager(); var Db = new ApricotContext(); var user = Db.Users.First(u => u.UserName == model.UserName); idManager.ClearUserRoles(user.Id); foreach (var role in model.Roles) { if (role.Selected) { idManager.AddUserToRole(user.Id, role.RoleName); } } return(RedirectToAction("index")); } return(View()); }
public ActionResult ConfirmDecision(String decision, Int64 id) { ApricotContext Db = new ApricotContext(); BillRepository billrepo = new BillRepository(Db); Bill bill = billrepo.GetByBillID(id); if (decision == "yes") { bill.Bill_Status = Data.Models.ApricotEnums.BillSatusEnum.CLOSED; billrepo.UpdateBill(bill); NotificationBL notibl = new NotificationBL(Db); notibl.NotificationOfCriditing(id); } //This means Bill is Still not Closed, Send Back the Index return(RedirectToAction("Index", "FManager")); }
public ActionResult Create() { var Db = new ApricotContext(); FullEmployee femp = new FullEmployee(); List <Department> departments = new List <Department>(); //Get All Departments DepartmentRepository departmentRepo = new DepartmentRepository(Db); departments = departmentRepo.GetAll().ToList(); var departmentList = new List <String>(0); foreach (var department in departments) { departmentList.Add(department.Dept_ID.ToString() + " - " + department.Dept_Name); } ViewBag.DepartmentList = departmentList; return(View(femp)); }
public ActionResult Edit(Int64 id) { var Db = new ApricotContext(); FillFullEmployee fillFullEmployee = new FillFullEmployee(Db); FullEmployee fullEmployee = new FullEmployee(); fullEmployee = fillFullEmployee.GetFullEmployeeByEmpNumber(id); List <Department> departments = new List <Department>(); //Get All Departments DepartmentRepository departmentRepo = new DepartmentRepository(Db); departments = departmentRepo.GetAll().ToList(); var departmentList = new List <String>(0); foreach (var department in departments) { departmentList.Add(department.Dept_ID.ToString() + " - " + department.Dept_Name); } ViewBag.DepartmentList = departmentList; return(View(fullEmployee)); }
public CommentBL(ApricotContext con) { _context = con; }