public ActionResult CreateSaleSession(AUSessionRecord session) { if (!ModelState.IsValid) { ErrorNotification("something wrong with the model - notify admin"); return View(); } //Recheck sale dates in case sale changed underneath session browser var sale = _saleRepo.GetById(session.AUSaleID); if (sale == null) throw new NopException("Sale not found - please notify admin"); if (session.SessionStartDateTime < sale.SaleStartDateTime || session.SessionEndDateTime > sale.SaleEndDateTime || session.SessionEndDateTime < sale.SaleStartDateTime || session.SessionStartDateTime > sale.SaleEndDateTime) { ErrorNotification("Session dates must be within sale dates"); return new NullJsonResult(); } var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer(); session.CreatedBy = CurrentCustomer.Username; session.UpdatedBy = CurrentCustomer.Username; session.CreatedOnDT = System.DateTime.UtcNow; session.UpdatedOnDT = session.CreatedOnDT; //TODO: CHECK SESSION DATES WITHIN SALE FROM-TO sale.AUSessionRecords.Add(session); _saleRepo.Update(sale); SuccessNotification("Session Added!", false); return new NullJsonResult(); }
public ActionResult ManageSaleSessions(int saleID = 0) { AUSessionRecord session = new AUSessionRecord(); session.AUSaleID = saleID; session.AUSessionID = 0; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%% session.AvailableAddresses.Add(new SelectListItem { Text = _localizationService.GetResource("Plugins.Misc.AUConsignor.SelectAddressMsg"), Value = "0" }); foreach (var c in _consignorService.GetAllAUAddresses()) { session.AvailableAddresses.Add(new SelectListItem { Text = c.Address1 + ", " + c.Address2 + ", " + c.City, Value = c.AUAddressID.ToString(), Selected = c.AUAddressID == session.AUAddressID }); } return View("~/Views/AUConsignor/ManageSaleSessions.cshtml", session); }