Esempio n. 1
0
        public ActionResult Edit(Models.Room.AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var room = _roomService.GetById(model.Id);

            if (room == null)
            {
                return(View("_ErrorNotExist"));
            }
            room.Name  = model.Name;
            room.Price = model.Price;
            room.Floor = model.Floor;
            var result = _roomService.Update(room);

            if (result <= 0)
            {
                ViewBag.ErrorMessage = "Not Edited";
                return(View(model));
            }
            return(RedirectToAction(nameof(RoomController.List)));
        }
Esempio n. 2
0
        public ActionResult Add(Models.Room.AddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Data.Entity.Room room = new Data.Entity.Room();
            room.Name  = model.Name;
            room.Price = model.Price;
            room.Floor = model.Floor;
            var result = _roomService.Add(room);

            if (result > 0)
            {
                return(RedirectToAction(nameof(RoomController.List)));
            }
            else
            {
                ViewBag.ErrorMessage = "Not Saved";
                return(View(model));
            }
        }