public ActionResult Edit(int id, WorkshopViewModel model)
        {
            Workshops workshop = new Workshops();

            workshop.InjectFrom(model);
            var workshopToUpdate = workshopService.UpdateWorkshop(workshop);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 2
0
        public ActionResult Edit(int id, WorkshopViewModel model)
        {
            Workshops edit = new Workshops();

            edit.InjectFrom(model);
            var createNewWorkshop = workshop.Update(edit);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
0
        public ActionResult Create(WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops newWorkshop = new Workshops();
                newWorkshop.InjectFrom(model);

                var createWorkshop = workshop.CreateWorkshops(newWorkshop);
                if (createWorkshop == null)
                {
                    ModelState.AddModelError("CompanyName", "Must be unique");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Create(WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops workshop = new Workshops();
                workshop.InjectFrom(model);
                var createNewWorkshop = workshopService.AddWorkshop(workshop);
                if (createNewWorkshop == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique!");

                    return(View(model));
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
        public ActionResult Edit(int id, WorkshopViewModel model)
        {
            if (ModelState.IsValid)
            {
                Workshops workshops = new Workshops();
                workshops.InjectFrom(model);
                var updateWorkshop = workShopService.UpdateAWorkshop(workshops);

                if (updateWorkshop == null)
                {
                    ModelState.AddModelError("Name", "The Name must be unique");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(model));
            }
        }