public ActionResult Create(int productTypeId) { var productType = _productTypeService.Find(productTypeId); PrepareProductEditing(productType, null); return(View("Edit")); }
public ActionResult Enable(ProductTypeModel[] model) { foreach (var item in model) { var type = _productTypeService.Find(item.Id); _productTypeService.Enable(type); } return(AjaxForm().ReloadPage()); }
public ProductAttribute Insert(ProductAttributeViewModel model, string CurrentId) { var data = new ProductAttribute(); data.Name = model.Name; data.ProductType = _productTypeService.Find(model.ProductTypeID); data.CreatDate = DateTime.Now; data.LastModifiedDate = DateTime.Now; base.Insert(data); return(data); }
public virtual IHttpActionResult Find([FromUri] ProductTypeFindRequest request) { var result = _productTypeService.Find(request.Id); if (result == null) { return(Fail("抱歉,没查到数据")); } return(Succeed(new ProductTypeFindResponse { Id = result.Id })); }
public ActionResult Edit(int id) { var productTypeItem = ProductTypeService.Find(id); if (productTypeItem == null) { return(RedirectToAction("Index")); } ViewBag.ListCategory = BuildListCategory(); var productTypeModel = new ProductTypeModels { Id = productTypeItem.ID, Name = productTypeItem.Name, ParentId = productTypeItem.Parent ?? 0, Number = productTypeItem.Number ?? 0, Status = productTypeItem.Status.HasValue && productTypeItem.Status.Value, ImageUrl = productTypeItem.Image, ImageBannerUrl = productTypeItem.ImageBanner, Icon = productTypeItem.Icon, Description = productTypeItem.Description }; return(View("Edit", productTypeModel)); }
private void ExecuteEdit(ProductTypeIndexViewModel model, ReferenceKeys.ApprovalStatus statusApproval, ReferenceKeys.EmailContent emailTemplate, bool sendEmail = false) { try { var obj = model.ViewModel; var data = _productTypeService.Find(model.ViewModel.ProdCode); var old = Mapper.Map <ProductTypeFormViewModel>(data); obj.CreatedBy = old.CreatedBy; obj.CreatedDate = old.CreatedDate; if (statusApproval == ReferenceKeys.ApprovalStatus.Edited) { // do nothing } else if (statusApproval == ReferenceKeys.ApprovalStatus.AwaitingAdminApproval) { obj = old; } else if (statusApproval == ReferenceKeys.ApprovalStatus.Completed) { obj = old; obj.LastApprovedBy = CurrentUser.USER_ID; obj.LastApprovedDate = DateTime.Now; } if (obj.IsDeleted == true) { obj.IsDeleted = false; } else { obj.IsDeleted = true; } obj.ModifiedBy = CurrentUser.USER_ID; obj.ModifiedDate = DateTime.Now; obj.ApprovalStatus = _refService.GetReferenceByKey(statusApproval).REFF_ID; model.ViewModel = obj; var parameters = new Dictionary <string, string>(); parameters.Add("product_type", data.PRODUCT_TYPE); parameters.Add("date", DateTime.Now.ToString("dddd, MMM dd yyyy")); // without time //parameters.Add("date", DateTime.Now.ToString("dddd, MMM dd yyyy hh:mm:ss")); // with time parameters.Add("creator", String.Format("{0} {1}", data.CREATOR.FIRST_NAME, data.CREATOR.LAST_NAME)); parameters.Add("approval_status", data.APPROVALSTATUS.REFF_VALUE); parameters.Add("url_detail", Url.Action("Detail", "ProductType", new { id = data.PROD_CODE }, this.Request.Url.Scheme)); parameters.Add("url_approve", Url.Action("Approve", "ProductType", new { id = data.PROD_CODE }, this.Request.Url.Scheme)); bool success = _productTypeService.Edit(Mapper.Map <CustomService.Data.MASTER_PRODUCT_TYPE>(obj), (int)Enums.MenuList.ProductType, (int)Enums.ActionType.Modified, (int)CurrentUser.UserRole, CurrentUser.USER_ID); if (success) { if (sendEmail) { var mailContent = _refService.GetMailContent((int)emailTemplate, parameters); var sender = _refService.GetUserEmail(CurrentUser.USER_ID); var display = ReferenceLookup.Instance.GetReferenceKey(ReferenceKeys.EmailSender.AdminCreator); var sendToId = _refService.GetReferenceByKey(ReferenceKeys.Approver.AdminApprover).REFF_VALUE; var sendTo = _refService.GetUserEmail(sendToId); AddMessageInfo(Constans.SubmitMessage.Updated + "<br />Sending email", Enums.MessageInfoType.Success); bool mailStatus = ItpiMailer.Instance.SendEmail(new string[] { sendTo }, null, null, null, mailContent.EMAILSUBJECT, mailContent.EMAILCONTENT, true, sender, display); if (!mailStatus) { AddMessageInfo("Send email failed! Please try again", Enums.MessageInfoType.Warning); } else { AddMessageInfo("Email sent!", Enums.MessageInfoType.Success); } } else { AddMessageInfo(Constans.SubmitMessage.Updated, Enums.MessageInfoType.Success); } } else { AddMessageInfo("Submit failed! Please try again", Enums.MessageInfoType.Error); } } catch (Exception ex) { var msg = String.Format("Message: {0}\nStack Trace: {1}\nInner Exception: {2}", ex.Message, ex.StackTrace, ex.InnerException); AddMessageInfo(msg, Enums.MessageInfoType.Error); } }