public bool UpdateUnit(UnitMasterVM unitVM) { try { if (unitVM != null) { tblUnitMaster unit = _UnitRepository.GetById(unitVM.UnitId); unit.Unit = unitVM.Unit; unit.abbreviation = unitVM.abbreviation; unit.UnitId = unitVM.UnitId; unit.IsDeleted = false; _UnitRepository.Update(unit); _unitOfWork.Complete(); return(true); } else { return(false); } } catch (Exception e) { throw e; } }
public UnitMasterVM GetByIdUnit(int id) { var item = _UnitRepository.GetById(id); UnitMasterVM _unitVM = new UnitMasterVM(); _unitVM.Unit = item.Unit; _unitVM.abbreviation = item.abbreviation; _unitVM.UnitId = item.UnitId; return(_unitVM); }
public List <UnitMasterVM> GetAllUnitsVM() { var unitList = _UnitRepository.GetAll(x => x.IsDeleted == false); List <UnitMasterVM> _unitVMList = new List <UnitMasterVM>(); foreach (var item in unitList) { UnitMasterVM _unitVM = new UnitMasterVM(); _unitVM.Unit = item.Unit; _unitVM.abbreviation = item.abbreviation; _unitVM.UnitId = item.UnitId; _unitVMList.Add(_unitVM); } return(_unitVMList); }
public ActionResult AddOrEditUnit(int id = 0) { UnitMasterVM unitVM = new UnitMasterVM(); if (id == 0) { //add return(PartialView(unitVM)); } else { //update unitVM = _UnitService.GetByIdUnit(id); return(PartialView(unitVM)); } }
public ActionResult AddOrEditUnit(UnitMasterVM unitVM) { try { if (ModelState.IsValid) { bool status = false; if (unitVM.UnitId == 0) { status = _UnitService.AddUnit(unitVM); if (status) { return(Json(new { success = true, message = "Saved Successfully...!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error..!" }, JsonRequestBehavior.AllowGet)); } } else { status = _UnitService.UpdateUnit(unitVM); if (status) { return(Json(new { success = true, message = "Updated Successfully...!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error..!" }, JsonRequestBehavior.AllowGet)); } } } else { return(PartialView(unitVM)); } } catch (Exception e) { throw e; } }