public ActionResult Create([Bind(Include = "SaleInvoiceID,InvoiceDate,InvoiceNo,SaleInvoiceStatusID,CustomerID,BusinessName,ContactName,Address,City,Postcode,Country,IntPhoneNo,EMailContact,AirportDestCity,ShippingDate,ArrivalDate,DomesticFlight,InternationalFlight,Products,TotalQuan,TotalGAmt,EstBoxes,BoxCharges,DomesticFreightCharges,IntFreightCharges,TTFee,TotalFreight,PreviousCredit,TotalPayableAmt")] Models.SaleInvoice.SaleInvoiceViewModel ViewModel) { if (Common.Props.LoginUser == null) { return(RedirectToAction("Login", "Users", new { ReturnUrl = "/SaleInvoice/Create" })); } else if (Common.Props.LoginUser != null && !(Common.Props.LoginUser.Role == Models.Users.eUserRoleID.Admin)) { return(RedirectToAction("PermissionDenied", "Home")); } else if (ViewModel.Products.Count(r => r.Qty > 0) == 0) { ModelState.AddModelError("", "You have not entered any quantity. Please enter quantity before proceed."); } if (ModelState.IsValid) { Models.Template.SavingResult SavingRes = DALObj.SaveRecord(ViewModel); if (Common.Functions.SetAfterSaveResult(ModelState, SavingRes)) { return(RedirectToAction("Index")); } } return(View(ViewModel)); }
public ActionResult UpdateStock(int ProductID, int Quan)//(string ProductID, string Quan) { if (Common.Props.LoginUser == null) { return(Json(new { Response = "Please login" })); } else if (Common.Props.LoginUser != null && Common.Props.LoginUser.Role != Models.Users.eUserRoleID.Admin) { return(Json(new { Response = "You don't have permission to update stock." })); } Models.Template.SavingResult res = UpdateStockDALObj.UpdateInventory(ProductID, Quan); switch (res.ExecutionResult) { case Models.Template.eExecutionResult.CommitedSucessfuly: return(Json(new { Response = "Saved" })); case Models.Template.eExecutionResult.ErrorWhileExecuting: return(Json(new { Response = "Exception : " + res.Exception.Message })); case Models.Template.eExecutionResult.ValidationError: return(Json(new { Response = "Validaiton Error : " + res.ValidationError })); default: return(Json(new { Response = "" })); } //return View(); }
public ActionResult Create([Bind(Include = "UserID,BusinessName,ContactName,EMailID,Password,Address,City,Postcode,Country,IntPhoneNo,AirportDestCity,IsApproved")] Models.Customer.CustomerViewModel ViewModel) { //if (Common.Props.LoginUser == null) //{ // return RedirectToAction("Login", "Users", new { ReturnUrl = "/Customer/Create" }); //} //else if (Common.Props.LoginUser != null && Common.Props.LoginUser.Role != Models.Users.eUserRoleID.Admin) //{ // return RedirectToAction("PermissionDenied", "Home"); //} if (ModelState.IsValid) { Models.Template.SavingResult SavingRes = DALObj.SaveRecord(ViewModel); if (Common.Functions.SetAfterSaveResult(ModelState, SavingRes)) { if (Common.Props.LoginUser == null) { //Task.Run( async() => { // await SendApprovalEmailToAdmins((int)SavingRes.PrimeKeyValue); //}); SendApprovalEmailToAdmins((int)SavingRes.PrimeKeyValue); return(RedirectToAction("RegistrationConfirm", "Customer", new { UserID = (int)SavingRes.PrimeKeyValue })); } else { return(RedirectToAction("Index")); } } } return(View(ViewModel)); }
public ActionResult Create([Bind(Include = "BoxListID,SaleInvoiceID,BoxListDetails")] Models.SaleInvoice.BoxListViewModel ViewModel) { if (Common.Props.LoginUser == null) { return(RedirectToAction("Login", "Users", new { ReturnUrl = "/SaleInvoice/Index" })); } else if (Common.Props.LoginUser != null && !(Common.Props.LoginUser.Role == Models.Users.eUserRoleID.Admin)) { return(RedirectToAction("PermissionDenied", "Home")); } //else if (ViewModel.Products.Count(r => r.Qty > 0) == 0) //{ // ModelState.AddModelError("", "You have not entered any quantity. Please enter quantity before proceed."); //} if (ModelState.IsValid) { Models.Template.SavingResult SavingRes = DALObj.SaveRecord(ViewModel); if (Common.Functions.SetAfterSaveResult(ModelState, SavingRes)) { return(RedirectToAction("Index")); } } return(View(ViewModel)); }
public ActionResult Create([Bind(Include = "SaleOrderID,CustomerID,SODate,SONo,CustomerID,BusinessName,ContactName,Address,City,Postcode,Country,IntPhoneNo,EMailContact,AirportDestCity,EstDelDate,Products")] Models.SaleOrder.SaleOrderViewModel ViewModel) { if (Common.Props.LoginUser == null) { return(RedirectToAction("Login", "Users", new { ReturnUrl = "/SaleOrder/Create" })); } else if (Common.Props.LoginUser != null && !(Common.Props.LoginUser.Role == Models.Users.eUserRoleID.Admin || Common.Props.LoginUser.Role == Models.Users.eUserRoleID.Customer)) { return(RedirectToAction("PermissionDenied", "Home")); } else if (ViewModel.Products.Count(r => r.OrderQty > 0) == 0) { ModelState.AddModelError("", "You have not entered any order. Please enter order quantity before proceed."); } if (ModelState.IsValid) { Models.Template.SavingResult SavingRes = DALObj.SaveRecord(ViewModel); if (Common.Functions.SetAfterSaveResult(ModelState, SavingRes)) { return(RedirectToAction("Index")); } } return(View(ViewModel)); }
public SavingResult ApproveUser(int UserID, bool Approval) { SavingResult res = new Models.Template.SavingResult(); using (dbUltraCoralEntities db = new DAL.dbUltraCoralEntities()) { tblUser SaveModel = db.tblUsers.Find(UserID); if (SaveModel == null) { res.ExecutionResult = eExecutionResult.ValidationError; res.ValidationError = "Invalid request. User has been deleted or moved."; return(res); } SaveModel.IsApproved = Approval; SaveModel.redt = DateTime.Now; SaveModel.reuid = (Common.Props.LoginUser != null? (int?)Common.Props.LoginUser.UserID : null); db.tblUsers.Attach(SaveModel); db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified; //-- try { db.SaveChanges(); res.PrimeKeyValue = SaveModel.UserID; res.ExecutionResult = eExecutionResult.CommitedSucessfuly; } catch (Exception ex) { ex = Common.Functions.FindFinalError(ex); res.ExecutionResult = eExecutionResult.ErrorWhileExecuting; res.Exception = ex; } } return(res); }