public ActionResult update(Guid id)
        {
            ExpanseTypesRepositery expTypeRep   = new ExpanseTypesRepositery();
            ExpanseTypes           expTypes     = expTypeRep.getById(id);
            ExpanseTypesModel      expTypeModel = new ExpanseTypesModel();

            if (!ModelState.IsValid)
            {
                TvasRepositery tvaRepo = new TvasRepositery();
                var            tvaLis  = tvaRepo.allTvas().ToList();
                expTypeModel.tvaList        = tvaLis;
                expTypeModel.ExpenseType_ID = expTypes.ExpenseType_ID;
                expTypeModel.Name           = expTypes.Name;
                expTypeModel.Ceiling        = expTypes.Ceiling;
                expTypeModel.Fixed          = expTypes.Fixed;
                expTypeModel.OnlyManagers   = expTypes.OnlyManagers;
                return(View("EditExpansesTypes", expTypeModel));
            }
            String  name         = Convert.ToString(Request.Form["Name"]);
            double  ceiling      = Convert.ToDouble(Request.Form["Ceiling"]);
            Boolean fixe         = Convert.ToBoolean(Request.Form["Fixed"]);
            Boolean OnlyManagers = Convert.ToBoolean(Request.Form["OnlyManagers"]);

            expTypeRep.updateExpanseType(expTypes, name, ceiling, fixe, OnlyManagers);
            return(RedirectToAction("AllExpanseTypes"));
        }
        public ActionResult createExpansTypes(ExpanseTypesModel expansTypeModel)
        {
            if (Convert.ToBoolean(Request.Form["Fixed"]) == true)
            {
            }
            if (!ModelState.IsValid)
            {
                TvasRepositery tvaRepo = new TvasRepositery();
                var            tvaLis  = tvaRepo.allTvas().ToList();
                expansTypeModel.tvaList = tvaLis;
                return(View("ExpansTypeFormulaire", expansTypeModel));
            }
            ExpanseTypes           expansType = new ExpanseTypes();
            ExpanseTypesRepositery expTypeRep = new ExpanseTypesRepositery();

            expansType.ExpenseType_ID = Guid.NewGuid();
            expansType.Name           = Convert.ToString(Request.Form["Name"]);
            if (Request.Form["Ceiling"] == null || string.IsNullOrWhiteSpace(Request.Form["Ceiling"]))
            {
                expansType.Ceiling = 0;
            }
            else
            {
                expansType.Ceiling = Convert.ToDouble(Request.Form["Ceiling"]);
            }
            expansType.Fixed        = Convert.ToBoolean(Request.Form["Fixed"]);
            expansType.OnlyManagers = Convert.ToBoolean(Request.Form["OnlyManagers"]);
            expansType.Tva_ID       = new Guid(Convert.ToString(Request.Form["tvaSelect"]));
            expTypeRep.AddExpanseType(expansType);
            return(RedirectToAction("AllExpanseTypes"));
        }
 public void delete(ExpanseTypes expType)
 {
     using (new NotesDeFraisEntities())
     {
         e.ExpanseTypes.Remove(expType);
     }
 }
        public ActionResult DeleteConfirmed(Guid id)
        {
            ExpanseTypes expanseTypes = db.ExpanseTypes.Find(id);

            db.ExpanseTypes.Remove(expanseTypes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ExpanseTypes getById(Guid id)
 {
     using (new NotesDeFraisEntities())
     {
         ExpanseTypes expType = (from c in e.ExpanseTypes where c.ExpenseType_ID == id select c).FirstOrDefault();
         return(expType);
     }
 }
 public void AddExpanseType(ExpanseTypes expanseType)
 {
     using (new NotesDeFraisEntities())
     {
         e.ExpanseTypes.Add(expanseType);
         e.SaveChanges();
     }
 }
 public ActionResult Edit([Bind(Include = "ExpenseType_ID,Name,Ceiling,Fixed,OnlyManagers,Tva_ID")] ExpanseTypes expanseTypes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expanseTypes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Tva_ID = new SelectList(db.Tvas, "TVA_ID", "Name", expanseTypes.Tva_ID);
     return(View(expanseTypes));
 }
 public void updateExpanseType(ExpanseTypes expType, String name, double celling, Boolean fix, Boolean only)
 {
     using (new NotesDeFraisEntities())
     {
         expType.Name         = name;
         expType.Ceiling      = celling;
         expType.Fixed        = fix;
         expType.OnlyManagers = only;
         e.SaveChanges();
     }
 }
        public ActionResult Create([Bind(Include = "ExpenseType_ID,Name,Ceiling,Fixed,OnlyManagers,Tva_ID")] ExpanseTypes expanseTypes)
        {
            if (ModelState.IsValid)
            {
                expanseTypes.ExpenseType_ID = Guid.NewGuid();
                db.ExpanseTypes.Add(expanseTypes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Tva_ID = new SelectList(db.Tvas, "TVA_ID", "Name", expanseTypes.Tva_ID);
            return(View(expanseTypes));
        }
        public ActionResult edit(Guid id)
        {
            ExpanseTypesRepositery expTypeRep   = new ExpanseTypesRepositery();
            ExpanseTypes           expTypes     = expTypeRep.getById(id);
            ExpanseTypesModel      expTypeModel = new ExpanseTypesModel();

            expTypeModel.ExpenseType_ID = expTypes.ExpenseType_ID;
            expTypeModel.Name           = expTypes.Name;
            expTypeModel.Ceiling        = expTypes.Ceiling;
            expTypeModel.Fixed          = expTypes.Fixed;
            expTypeModel.OnlyManagers   = expTypes.OnlyManagers;
            return(View("EditExpansesTypes", expTypeModel));
        }
        // GET: ExpanseTypes/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpanseTypes expanseTypes = db.ExpanseTypes.Find(id);

            if (expanseTypes == null)
            {
                return(HttpNotFound());
            }
            return(View(expanseTypes));
        }
        // GET: ExpanseTypes/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpanseTypes expanseTypes = db.ExpanseTypes.Find(id);

            if (expanseTypes == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Tva_ID = new SelectList(db.Tvas, "TVA_ID", "Name", expanseTypes.Tva_ID);
            return(View(expanseTypes));
        }
        public ActionResult Delete(Guid id)
        {
            ExpanseTypesRepositery expTypeRepo = new ExpanseTypesRepositery();
            ExpanseRepositery      expRep      = new ExpanseRepositery();
            List <Expanses>        expList     = expRep.GetExpansesByIdExpanseTypes(id).ToList();

            foreach (var expanse in expList)
            {
                expRep.Delete(expanse);
            }
            expRep.Save();
            ExpanseTypes expanseType = expTypeRepo.getById(id);

            expTypeRepo.delete(expanseType);
            expTypeRepo.Save();
            return(RedirectToAction("AllExpanseTypes"));
        }