Beispiel #1
0
        public ActionResult Create()
        {
            var model = new ServicesCreateViewModel();

            PrepareViewModel(model);
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Create(ServicesCreateViewModel model, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = model.Map <Services>();

            Services.Create(service);

            return(RedirectToLocal(redirectUrl));
        }
Beispiel #3
0
        public void PrepareViewModel(ServicesCreateViewModel model)
        {
            var units = Units.Get().Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = Convert.ToString(s.UnitsId)
            }).ToList();
            var types = Types.Get().Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = Convert.ToString(s.TypeServicesId)
            }).ToList();

            model.Types = types;
            model.Units = units;
        }
Beispiel #4
0
        public ActionResult Edit(ServicesCreateViewModel model, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model: model));
            }

            var serv = Services.GetById(model.ServicesId);

            if (serv != null)
            {
                Mapper.Map(model, serv);
                Services.Update(serv);
            }

            return(RedirectToLocal(redirectUrl));
        }