public ActionResult Create(UnitValue model) { if (ModelState.IsValid) { try { _unitValueService.CreateUnitValue(model); this.ShowMessage("Unit value created successfully", MessageType.Success); return RedirectToAction("Index"); } catch (Exception ex) { this.ShowMessage("Error on data generation with the following details " + ex.Message, MessageType.Error); } } ViewBag.UnitTypeId = new SelectList(_unitTypeService.GetUnitTypes(), "UnitTypeId", "Name", model.UnitTypeId); return View(model); }
public void UpdateUnitValue(UnitValue unitValue) { _unitValueRepository.Update(unitValue); Save(); }
public void CreateUnitValue(UnitValue unitValue) { _unitValueRepository.Add(unitValue); Save(); }
public ActionResult Edit(UnitValue model) { if (ModelState.IsValid) { UnitValue unitValue = _unitValueService.GetUnitValue(model.UnitValueId); if (unitValue == null) { this.ShowMessage("Sorry! Data not found. You've been redirected to the default page instead.", MessageType.Error); return RedirectToAction("Index"); } try { unitValue.Name = model.Name; unitValue.Note = model.Note; unitValue.UnitTypeId = model.UnitTypeId; _unitValueService.UpdateUnitValue(unitValue); this.ShowMessage("Unit value updated successfully", MessageType.Success); return RedirectToAction("Index"); } catch (Exception ex) { this.ShowMessage("Error on data generation with the following details " + ex.Message, MessageType.Error); } } ViewBag.UnitTypeId = new SelectList(_unitTypeService.GetUnitTypes(), "UnitTypeId", "Name", model.UnitTypeId); return View(model); }