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(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")); }