Example #1
0
        public ActionResult Create(ReservationTypeViewModel reservation)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                var absencType = new ReservationType
                {
                    Id     = reservation.Id,
                    Name   = reservation.Name,
                    Number = reservation.Number
                };
                var isSuccess = _repo.Create(absencType);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something went wrong");
                    return(View(reservation));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
 public ActionResult Edit(int id, ReservationTypeViewModel model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             ModelState.AddModelError("", "Something went wrong");
             return(View(model));
         }
         var ReservationType = new ReservationType
         {
             Id     = model.Id,
             Name   = model.Name,
             Number = model.Number
         };
         var isSuccess = _repo.Update(ReservationType);
         if (!isSuccess)
         {
             ModelState.AddModelError("", "Something went wrong");
             return(View(model));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         ModelState.AddModelError("", "Something went wrong");
         return(View());
     }
 }
Example #3
0
        // GET: ReservationTypeController/Edit/5
        public ActionResult Edit(int id)
        {
            if (!_repo.IsExist(id))
            {
                return(NotFound());
            }
            var AbsenceType = _repo.GetById(id);
            var model       = new ReservationTypeViewModel
            {
                Id     = AbsenceType.Id,
                Name   = AbsenceType.Name,
                Number = AbsenceType.Number
            };

            return(View(model));
        }