Ejemplo n.º 1
0
        public void Edit(ExpanseTypeViewModels model)
        {
            ExpanseType expanseType = Repository.GetById(model.Id);

            expanseType = Mapper.ModelToData(expanseType, model);
            Repository.Save();
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public void Add(ExpanseTypeViewModels model)
        {
            ExpanseType expanseType = new ExpanseType();

            expanseType.ExpenseType_ID = Guid.NewGuid();

            Repository.Add(Mapper.ModelToData(expanseType, model));
            Repository.Save();
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public ActionResult Details(string id)
        {
            ExpanseTypeViewModels model = Service.GetById(id);

            if (model == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            return(View(model));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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
                }));
            }
        }
Ejemplo n.º 8
0
 public bool IsValid(ExpanseTypeViewModels model)
 {
     return(!model.Fixed || (model.Fixed && model.Ceilling != null));
 }