// GET: /ProductMaster/Create public ActionResult Create() { ProductStyle vm = new ProductStyle(); vm.IsActive = true; return(View("Create", vm)); }
public IHttpActionResult DeleteProductStyle(int id) { ProductStyle productStyle = db.ProductStyles.Find(id); productStyle.IsActive = false; db.SaveChanges(); return(Ok(true)); }
public ActionResult DeleteConfirmed(int id) { ProductStyle ProductManufacturingStyle = db.ProductStyle.Find(id); db.ProductStyle.Remove(ProductManufacturingStyle); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult PutProductStyle(int id, ProductStyle productStyle) { var model = db.ProductStyles.Where(x => x.IsActive == true && x.Id == id).FirstOrDefault(); model.StyleSKU = productStyle.StyleSKU; model.IsActive = productStyle.IsActive; db.SaveChanges(); return(Ok(true)); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { ProductStyle pt = _ProductManufacturingStyleService.GetProductManufacturingStyle(id); if (pt == null) { return(HttpNotFound()); } return(View(pt)); }
public IHttpActionResult PostProductStyle(ProductStyle productStyle) { ProductStyle model = new ProductStyle(); model.StyleSKU = productStyle.StyleSKU; model.IsActive = productStyle.IsActive; db.ProductStyles.Add(model); db.SaveChanges(); return(Ok(true)); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { ProductStyle pt = _ProductStyleService.Find(id); if (pt == null) { return(HttpNotFound()); } return(View("Create", pt)); }
public IHttpActionResult GetProductStyle(int id) { ProductStyle productStyle = db.ProductStyles.Find(id); if (productStyle == null) { return(NotFound()); } return(Ok(productStyle)); }
public ActionResult Edit(ProductStyle pt) { if (ModelState.IsValid) { pt.ModifiedDate = DateTime.Now; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Modified; _ProductManufacturingStyleService.Update(pt); _unitOfWork.Save(); return(RedirectToAction("Index")); } return(View(pt)); }
public IActionResult AddStyleToProduct(int id, int styleid) { var newConnection = new ProductStyle() { ProductId = id, StyleId = styleid }; System.Console.WriteLine("/////////////////////"); System.Console.WriteLine(id); dbContext.ProductStyles.Add(newConnection); dbContext.SaveChanges(); return(Redirect("/DisplayProductPage/" + id)); }
public ProductStyleDto get(string id) { try { ProductStyle bb = _context.ProductStyle.Find(id); // _context.Entry(bb).Reference(b => b.Bank).Load(); // _context.Entry(bb).Reference(b => b.Province).Load(); return(mapper.Map <ProductStyle, ProductStyleDto>(bb)); } catch (Exception) { return(null); } }
// GET: /ProductMaster/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductStyle ProductManufacturingStyle = db.ProductStyle.Find(id); if (ProductManufacturingStyle == null) { return(HttpNotFound()); } return(View(ProductManufacturingStyle)); }
public string create(ProductStyleDto tProductStyleDto) { try { ProductStyle tProductStyleNew = mapper.Map <ProductStyleDto, ProductStyle>(tProductStyleDto); tProductStyleNew.Id = Guid.NewGuid().ToString(); tProductStyleNew.CreateDate = DateTime.Now; _context.ProductStyle.Add(tProductStyleNew); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public string delete(string id) { try { ProductStyle tProductStyleRemove = _context.ProductStyle.Find(id); if (tProductStyleRemove == null) { return("1"); } _context.ProductStyle.Remove(tProductStyleRemove); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public string lockItem(string id) { try { ProductStyle tProductStyleBlock = _context.ProductStyle.Find(id); if (tProductStyleBlock == null) { return("1"); } tProductStyleBlock.Status = false; _context.ProductStyle.Update(tProductStyleBlock); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public ProductStyle GetCode(string sku) { ProductStyle model = new ProductStyle(); bool data = db.ProductStyles.Any(x => x.StyleSKU == sku && x.IsActive == true); if (data == true) { model = db.ProductStyles.Where(x => x.IsActive == true && x.StyleSKU == sku).FirstOrDefault(); } else { model.StyleSKU = sku; model.IsActive = true; db.ProductStyles.Add(model); db.SaveChanges(); var list = db.ProductStyles.Where(x => x.IsActive == true).ToList(); model = list.LastOrDefault(); } return(model); }
// GET: /ProductMaster/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductStyle ProductStyle = _ProductStyleService.Find(id); if (ProductStyle == null) { return(HttpNotFound()); } ReasonViewModel vm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", vm)); }
public string update(ProductStyleDto tProductStyleDto) { try { ProductStyle tProductStyleUpdate = _context.ProductStyle.Find(tProductStyleDto.Id); if (tProductStyleUpdate == null) { return("1"); } tProductStyleUpdate.Name = tProductStyleDto.Name; tProductStyleUpdate.Id = tProductStyleDto.Id; tProductStyleUpdate.Status = tProductStyleDto.Status; tProductStyleUpdate.CreateDate = tProductStyleDto.CreateDate; tProductStyleUpdate.CreateUser = tProductStyleDto.CreateUser; _context.ProductStyle.Update(tProductStyleUpdate); _context.SaveChanges(); return("0"); } catch (Exception) { return("1"); } }
public void Delete(ProductStyle pt) { _unitOfWork.Repository <ProductStyle>().Delete(pt); }
public ProductStyle Create(ProductStyle pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <ProductStyle>().Insert(pt); return(pt); }
public ActionResult Post(ProductStyle vm) { ProductStyle pt = vm; if (ModelState.IsValid) { if (vm.ProductStyleId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ProductStyleService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductStyle).DocumentTypeId, DocId = pt.ProductStyleId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("Create").Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProductStyle temp = _ProductStyleService.Find(pt.ProductStyleId); ProductStyle ExRec = Mapper.Map <ProductStyle>(temp); temp.ProductStyleName = pt.ProductStyleName; temp.IsActive = pt.IsActive; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _ProductStyleService.Update(temp); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductStyle).DocumentTypeId, DocId = temp.ProductStyleId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } return(View("Create", vm)); }
public void Update(ProductStyle pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <ProductStyle>().Update(pt); }
public ProductStyle Add(ProductStyle pt) { _unitOfWork.Repository <ProductStyle>().Insert(pt); return(pt); }
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "alpha" || e.CommandName == "NoFilter") { String value = null; switch (e.CommandName) { case ("alpha"): { value = string.Format("{0}%", e.CommandArgument); break; } case ("NoFilter"): { value = "%"; break; } } ObjectDataSource1.SelectParameters["ProductStyleName"].DefaultValue = value; ObjectDataSource1.DataBind(); RadGrid1.Rebind(); } else if (e.CommandName == "QuickUpdate") { string ProductStyleID, Priority, IsAvailable; var oProductStyle = new ProductStyle(); foreach (GridDataItem item in RadGrid1.Items) { ProductStyleID = item.GetDataKeyValue("ProductStyleID").ToString(); Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim(); IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); oProductStyle.ProductStyleQuickUpdate( ProductStyleID, IsAvailable, Priority ); } } else if (e.CommandName == "DeleteSelected") { var oProductStyle = new ProductStyle(); foreach (GridDataItem item in RadGrid1.SelectedItems) { string strProductStyleImage = ((HiddenField)item.FindControl("hdnProductStyleImage")).Value; if (!string.IsNullOrEmpty(strProductStyleImage)) { string strSavePath = Server.MapPath("~/res/productstyle/" + strProductStyleImage); if (File.Exists(strSavePath)) { File.Delete(strSavePath); } } } } else if (e.CommandName == "PerformInsert" || e.CommandName == "Update") { var command = e.CommandName; var row = command == "PerformInsert" ? (GridEditFormInsertItem)e.Item : (GridEditFormItem)e.Item; var FileProductStyleImage = (RadUpload)row.FindControl("FileProductStyleImage"); string strProductStyleName = ((TextBox)row.FindControl("txtProductStyleName")).Text.Trim(); string strProductStyleNameEn = ((TextBox)row.FindControl("txtProductStyleNameEn")).Text.Trim(); string strConvertedProductStyleName = Common.ConvertTitle(strProductStyleName); string strProductStyleImage = FileProductStyleImage.UploadedFiles.Count > 0 ? FileProductStyleImage.UploadedFiles[0].GetName() : ""; string strIsAvailable = ((CheckBox)row.FindControl("chkIsAvailable")).Checked.ToString(); string strPriority = ((RadNumericTextBox)row.FindControl("txtPriority")).Text.Trim(); string strProductID = string.IsNullOrEmpty(Request.QueryString["pi"]) ? "" : Request.QueryString["pi"]; //string strContent = FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContent")).Content.Trim()); //string strContentEn = FCKEditorFix.Fix(((RadEditor)row.FindControl("txtContentEn")).Content.Trim()); var oProductStyle = new ProductStyle(); if (e.CommandName == "PerformInsert") { strProductStyleImage = oProductStyle.ProductStyleInsert( strProductStyleName, strProductStyleNameEn, strConvertedProductStyleName, strProductStyleImage, strIsAvailable, strPriority, strProductID ); string strFullPath = "~/res/productstyle/" + strProductStyleImage; if (!string.IsNullOrEmpty(strProductStyleImage)) { FileProductStyleImage.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); //string bgColor = "#ffffff"; //ResizeCropImage.ResizeWithBackGroundColor(strFullPath, 190, 120, bgColor); //ResizeCropImage.ResizeByWidth(strFullPath, 180); ResizeCropImage.ResizeByCondition(strFullPath, 200, 200); } RadGrid1.Rebind(); } else { var dsUpdateParam = ObjectDataSource1.UpdateParameters; var strProductStyleID = row.GetDataKeyValue("ProductStyleID").ToString(); var strOldProductStyleImage = ((HiddenField)row.FindControl("hdnProductStyleImage")).Value; var strOldImagePath = Server.MapPath("~/res/productstyle/" + strOldProductStyleImage); dsUpdateParam["ProductStyleName"].DefaultValue = strProductStyleName; dsUpdateParam["ProductStyleNameEn"].DefaultValue = strProductStyleNameEn; dsUpdateParam["ConvertedProductStyleName"].DefaultValue = strConvertedProductStyleName; dsUpdateParam["ProductStyleImage"].DefaultValue = strProductStyleImage; dsUpdateParam["IsAvailable"].DefaultValue = strIsAvailable; dsUpdateParam["ProductID"].DefaultValue = strProductID; if (!string.IsNullOrEmpty(strProductStyleImage)) { var strFullPath = "~/res/productstyle/" + strConvertedProductStyleName + "-" + strProductStyleID + strProductStyleImage.Substring(strProductStyleImage.LastIndexOf('.')); if (File.Exists(strOldImagePath)) { File.Delete(strOldImagePath); } FileProductStyleImage.UploadedFiles[0].SaveAs(Server.MapPath(strFullPath)); //string bgColor = "#ffffff"; //ResizeCropImage.ResizeWithBackGroundColor(strFullPath, 180, 120, bgColor); ResizeCropImage.ResizeByCondition(strFullPath, 200, 200); //ResizeCropImage.ResizeByWidth(strFullPath, 180); } } } if (e.CommandName == "DeleteImage") { var oProductStyle = new ProductStyle(); var lnkDeleteImage = (LinkButton)e.CommandSource; var s = lnkDeleteImage.Attributes["rel"].ToString().Split('#'); var strProductStyleID = s[0]; var strProductStyleImage = s[1]; oProductStyle.ProductStyleImageDelete(strProductStyleID); DeleteImage(strProductStyleImage); RadGrid1.Rebind(); } }