public JsonResult Create(ProductModelVM vmObj) { bool isSaved = false; if (ModelState.IsValid) { var var = vmObj; isSaved = _Manager.Save(var.ProductModel); } if (isSaved) { status = true; message = "Succesfully Saved"; } else { message = "Error! Please try again."; } return(new JsonResult { Data = new { status = status, message = message } }); }
public ActionResult Add(ProductModelVM model) { if (ModelState.IsValid) { var promodel = rpproductmodel.FirstOrDefault(x => x.Name.ToLower() == model.Name.ToLower() || x.BarcodeValue == model.BarcodeValue); if (promodel != null) { ViewBag.IslemDurum = promodel.Name.ToLower() == model.Name.ToLower() ? EnumIslemDurum.IsimMevcut : EnumIslemDurum.BarkodMevcut; } else { ProductModel entity = new ProductModel { Name = model.Name, TradeMarkID = model.TradeMarkID, BarcodeValue = model.BarcodeValue }; rpproductmodel.Add(entity); ViewBag.IslemDurum = EnumIslemDurum.Basarili; } } else { ViewBag.IslemDurum = EnumIslemDurum.ValidationHata; } GetAllTradeMarks(); return(View(model)); }
public JsonResult Search(ProductModelVM vmObj) { var var = vmObj; var var2 = _Manager.GetBySearchItem(var.ProductModel); return(new JsonResult { Data = var2, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult Index() { var selectListItem = GetSelectListItems(); var model = new ProductModelVM(); model.GeneralCategoryList = selectListItem; model.ProductModel = new ProductModel(); return(View(model)); }
public ActionResult Edit(int id) { var entity = rpproductmodel.Find(id); ProductModelVM model = new ProductModelVM { ID = entity.ID, Name = entity.Name, TradeMarkID = entity.TradeMarkID, BarcodeValue = entity.BarcodeValue }; GetAllTradeMarks(); return(View(model)); }
public JsonResult Edit(ProductModelVM vmObj) { bool isUpdated = _Manager.Update(vmObj.ProductModel); if (isUpdated) { status = true; message = "Update Successfully!!"; } return(new JsonResult { Data = new { status = status, message = message } }); }
public ActionResult Edit(ProductModelVM model) { if (ModelState.IsValid) { var promodel = rpproductmodel.FirstOrDefault(x => (x.Name.ToLower() == model.Name.ToLower() || x.BarcodeValue == model.BarcodeValue) && x.ID != model.ID); if (promodel != null) { ViewBag.IslemDurum = promodel.Name.ToLower() == model.Name.ToLower() ? EnumIslemDurum.IsimMevcut : EnumIslemDurum.BarkodMevcut; } ProductModel entity = rpproductmodel.Find(model.ID); entity.Name = model.Name; entity.TradeMarkID = model.TradeMarkID; entity.BarcodeValue = model.BarcodeValue; entity.UpdateDate = DateTime.Now; rpproductmodel.SaveChanges(); ViewBag.IslemDurum = EnumIslemDurum.Basarili; } else { ViewBag.IslemDurum = EnumIslemDurum.ValidationHata; } GetAllTradeMarks(); return(View(model)); }