public ActionResult AddNew(PartsProductManuVeiwModel partsProductManuVeiwModel) { try { if (ModelState.IsValid) { PartsProductManufacturerRepository partsProductManufacturerRepository = new PartsProductManufacturerRepository(new AutoSolutionContext()); bool IsExist = partsProductManufacturerRepository.isExist(partsProductManuVeiwModel.PartsProductManufacturerName); if (!IsExist) { PartsProductManufacturer partsProductManufacturer = new PartsProductManufacturer(); partsProductManufacturer.PartsProductManufacturerName = partsProductManuVeiwModel.PartsProductManufacturerName; partsProductManufacturer.PartsProductManufacturerCode = partsProductManuVeiwModel.PartsProductManufacturerCode; _unitOfWork.PartsProductManufacturer.Add(partsProductManufacturer); _unitOfWork.Complete(); _unitOfWork.Dispose(); return(RedirectToAction("GetPartsProductsManu")); } else { return(RedirectToAction("GetPartsProductsManu")); } } } catch (Exception) { throw; } return(View()); }
public ActionResult Edit(string id) { try { if (string.IsNullOrEmpty(id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var item = _unitOfWork.PartsProductManufacturer.GetByID(Convert.ToInt32(id)); PartsProductManuVeiwModel partsProductManufacturerVM = new PartsProductManuVeiwModel(); partsProductManufacturerVM.PartsProductManufacturerId = item.PartsProductManufacturerId; partsProductManufacturerVM.PartsProductManufacturerName = item.PartsProductManufacturerName; partsProductManufacturerVM.PartsProductManufacturerCode = item.PartsProductManufacturerCode; if (partsProductManufacturerVM != null) { return(PartialView("_EditPartsProductsManu", partsProductManufacturerVM)); } else { return(HttpNotFound()); } } catch (Exception) { throw; } }
public PartsProductManuVeiwModel GetPartsProductManu(int PageNo, int TotalCount, string SearchTerm) { var partsProductManuVeiwModel = new PartsProductManuVeiwModel() { PartsProductManufacturerList = AutoSolutionContext.PartsProductManufacturers.OrderBy(x => x.PartsProductManufacturerName).Where(x => x.PartsProductManufacturerName.Contains(SearchTerm)).Skip((PageNo - 1) * 10).Take(10).ToList(), Pager = new Pager(TotalCount, PageNo, 10) }; return(partsProductManuVeiwModel); }
public ActionResult Edit(PartsProductManuVeiwModel PartsProductManuVeiwModel) { try { if (PartsProductManuVeiwModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PartsProductManufacturer partsProductManufacturer = new PartsProductManufacturer(); partsProductManufacturer = _unitOfWork.PartsProductManufacturer.GetByID(Convert.ToInt32(PartsProductManuVeiwModel.PartsProductManufacturerId)); partsProductManufacturer.PartsProductManufacturerName = PartsProductManuVeiwModel.PartsProductManufacturerName; partsProductManufacturer.PartsProductManufacturerCode = PartsProductManuVeiwModel.PartsProductManufacturerCode; _unitOfWork.PartsProductManufacturer.Update(partsProductManufacturer); _unitOfWork.Complete(); _unitOfWork.Dispose(); } catch (Exception) { throw; } return(RedirectToAction("GetPartsProductsManu")); }