public ActionResult Create(ServiceScheduleViewModel model) { var urlRefer = Request["UrlReferrer"]; if (ModelState.IsValid) { var serviceSchedule = new ServiceSchedule(); AutoMapper.Mapper.Map(model, serviceSchedule); serviceSchedule.IsDeleted = false; serviceSchedule.CreatedUserId = WebSecurity.CurrentUserId; serviceSchedule.ModifiedUserId = WebSecurity.CurrentUserId; serviceSchedule.AssignedUserId = WebSecurity.CurrentUserId; serviceSchedule.CreatedDate = DateTime.Now; serviceSchedule.ModifiedDate = DateTime.Now; serviceSchedule.Status = "pending"; ServiceScheduleRepository.InsertServiceSchedule(serviceSchedule); string prefix = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_ServiceSchedule"); serviceSchedule.Code = Erp.BackOffice.Helpers.Common.GetCode(prefix, serviceSchedule.Id); ServiceScheduleRepository.UpdateServiceSchedule(serviceSchedule); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True") { TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; ViewBag.closePopup = "true"; model.Id = serviceSchedule.Id; ViewBag.urlRefer = urlRefer; return(View(model)); } return(Redirect(urlRefer)); } return(View(model)); }
public ViewResult Create(int?CustomerId, DateTime date) { var model = new ServiceScheduleViewModel(); model.StartDate = date; model.DueDate = date.AddHours(1); //var branchId = Helpers.Common.CurrentUser.BranchId.Value; model.BranchId = null; model.CustomerId = CustomerId; return(View(model)); }
public ActionResult Detail(int?Id) { var ServiceSchedule = ServiceScheduleRepository.GetvwServiceScheduleById(Id.Value); var customerImagePath = Helpers.Common.GetSetting("uploads_image_path_customer"); var filepath = System.Web.HttpContext.Current.Server.MapPath("~" + customerImagePath); if (ServiceSchedule != null && ServiceSchedule.IsDeleted != true) { var model = new ServiceScheduleViewModel(); AutoMapper.Mapper.Map(ServiceSchedule, model); //kiem tra hinh co ton tai hay khong if (!string.IsNullOrEmpty(model.CustomerImage)) { model.CustomerImagePath = customerImagePath + model.CustomerImage; if (!System.IO.File.Exists(filepath + model.CustomerImage)) { model.CustomerImagePath = "/assets/img/no-avatar.png"; } else { model.CustomerImagePath = customerImagePath + model.CustomerImage; } } else if (string.IsNullOrEmpty(model.CustomerImage)) //Đã có hình { model.CustomerImagePath = "/assets/img/no-avatar.png"; } //if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) //{ // TempData["FailedMessage"] = "NotOwner"; // return RedirectToAction("Index"); //} return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Edit(ServiceScheduleViewModel model) { var urlRefer = Request["UrlReferrer"]; var serviceSchedule = ServiceScheduleRepository.GetServiceScheduleById(model.Id); AutoMapper.Mapper.Map(model, serviceSchedule); serviceSchedule.ModifiedUserId = WebSecurity.CurrentUserId; serviceSchedule.ModifiedDate = DateTime.Now; ServiceScheduleRepository.UpdateServiceSchedule(serviceSchedule); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess; if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True") { ViewBag.closePopup = "true"; model.Id = serviceSchedule.Id; ViewBag.urlRefer = urlRefer; return(View(model)); } return(Redirect(urlRefer)); }