public void Edit(ExpanseTypeViewModels model) { ExpanseType expanseType = Repository.GetById(model.Id); expanseType = Mapper.ModelToData(expanseType, model); Repository.Save(); }
public ActionResult CreateEdit(ExpanseTypeViewModels model) { if (!Service.IsValid(model)) { ModelState.AddModelError("Fixed", "Vous avez choisi une valeur fixe. Le plafond est donc obligatoire"); } if (ModelState.IsValid && Service.IsValid(model)) { if (string.IsNullOrEmpty(model.Id)) { Service.Add(model); } else { Service.Edit(model); } return(RedirectToAction("Index")); } ViewBag.Tva = new SelectList(TvaService.GetAll(), "TVA_ID", "Name"); return(View("Create", model)); }
public void Add(ExpanseTypeViewModels model) { ExpanseType expanseType = new ExpanseType(); expanseType.ExpenseType_ID = Guid.NewGuid(); Repository.Add(Mapper.ModelToData(expanseType, model)); Repository.Save(); }
public ExpanseType ModelToData(ExpanseType expanseType, ExpanseTypeViewModels model) { expanseType.Name = model.Name; expanseType.OnlyManagers = model.OnlyManager; expanseType.Tva_ID = new Guid(model.Tva_Id); expanseType.Ceiling = model.Ceilling; expanseType.Fixed = model.Fixed; return(expanseType); }
public ActionResult Details(string id) { ExpanseTypeViewModels model = Service.GetById(id); if (model == null) { return(new HttpStatusCodeResult(404)); } return(View(model)); }
public ActionResult Edit(string id) { ExpanseTypeViewModels model = Service.GetById(id); if (model == null) { return(new HttpStatusCodeResult(404)); } ViewBag.Tva = new SelectList(TvaService.GetAll(), "TVA_ID", "Name"); return(View("Create", model)); }
public ActionResult UpdateAmountField(string expanseTypeForAmount) { ExpanseTypeViewModels type = ExpanseTypeService.GetById(expanseTypeForAmount); if (type == null || !type.Fixed) { return(PartialView("_Amount_HT", new ExpansViewModels())); } else { return(PartialView("_Amount_HT", new ExpansViewModels { ExpanseType_ID = expanseTypeForAmount, Amount_HT = (double)type.Ceilling })); } }
public bool IsValid(ExpanseTypeViewModels model) { return(!model.Fixed || (model.Fixed && model.Ceilling != null)); }