public ActionResult Update(StationeryDetailsDTO stationery) { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreManager) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } if (ModelState.IsValid) { if (stationery.Supplier1 == stationery.Supplier2 || stationery.Supplier1 == stationery.Supplier3 || stationery.Supplier2 == stationery.Supplier3) { stationery.Error = new ErrorDTO(); stationery.Error.HasError = true; stationery.Error.Message = "Suppliers must be three different suppliers!"; stationery.Categories = StationeryService.Instance.GetAllCategories(); stationery.Suppliers = StationeryService.Instance.GetAllSuppliers(); return(View(stationery)); } Stationery newStationery = this.generateStationery(stationery); StationeryService.Instance.UpdateStationery(newStationery); this.generateSupplierTender(stationery.Supplier1, 1, newStationery.Id, stationery.Price1); this.generateSupplierTender(stationery.Supplier2, 2, newStationery.Id, stationery.Price2); this.generateSupplierTender(stationery.Supplier3, 3, newStationery.Id, stationery.Price3); return(RedirectToAction("Index")); } stationery.Categories = StationeryService.Instance.GetAllCategories(); stationery.Suppliers = StationeryService.Instance.GetAllSuppliers(); return(View(stationery)); } return(RedirectToAction("Index", "Login")); }
public ActionResult Create() { if (Session["existinguser"] != null) { LoginDTO currentUser = (LoginDTO)Session["existinguser"]; if (currentUser.RoleId != (int)Enums.Roles.StoreManager) { return(RedirectToAction("RedirectToClerkOrDepartmentView", "Login")); } StationeryDetailsDTO stationery = new StationeryDetailsDTO(); stationery.Categories = StationeryService.Instance.GetAllCategories(); stationery.Suppliers = StationeryService.Instance.GetAllSuppliers(); return(View(stationery)); } return(RedirectToAction("Index", "Login")); }
private Stationery generateStationery(StationeryDetailsDTO stationery) { Stationery newStationery = StationeryService.Instance.GetStationeryById(stationery.StationeryId); if (newStationery == null) { newStationery = new Stationery(); } newStationery.Id = stationery.StationeryId; newStationery.Code = stationery.Code; newStationery.Description = stationery.Description; newStationery.CategoryId = stationery.CategoryId; newStationery.UnitOfMeasure = Enum.GetName(typeof(Enums.UOM), stationery.UOM); newStationery.Bin = stationery.Bin; newStationery.Status = Enum.GetName(typeof(Enums.ActiveStatus), Enums.ActiveStatus.ACTIVE); return(newStationery); }
private StationeryDetailsDTO generateStationeryDetailsDTO(int stationeryId) { Stationery stationery = StationeryService.Instance.GetStationeryById(stationeryId); StationeryDetailsDTO stationeryDetails = new StationeryDetailsDTO(); stationeryDetails.StationeryId = stationery.Id; stationeryDetails.Code = stationery.Code; stationeryDetails.Description = stationery.Description; stationeryDetails.Bin = stationery.Bin; stationeryDetails.CategoryId = stationery.CategoryId; stationeryDetails.Supplier1 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 1).SupplierId; stationeryDetails.Supplier2 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 2).SupplierId; stationeryDetails.Supplier3 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 3).SupplierId; stationeryDetails.Price1 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 1).Price; stationeryDetails.Price2 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 2).Price; stationeryDetails.Price3 = stationery.SupplierTenders.SingleOrDefault(x => x.Rank == 3).Price; return(stationeryDetails); }