Пример #1
0
        public ActionResult Delete(int id)
        {
            var service = new RepService();
            var model   = service.GetRepByID(id);

            return(View(model));
        }
Пример #2
0
        public ActionResult Index()
        {
            var service = new RepService();
            var model   = service.GetReps();

            return(View(model));
        }
Пример #3
0
        public ActionResult DeletePost(int id)
        {
            var service = new RepService();

            service.DeleteRep(id);

            TempData["SaveResult"] = "Your rep was deleted";

            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Create(RepCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = new RepService();

            service.CreateRep(model);

            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Edit(int id)

        {
            var service = new RepService();
            var detail  = service.GetRepByID(id);
            var model   =
                new RepDetail
            {
                ID    = detail.ID,
                Name  = detail.Name,
                Email = detail.Email,
            };

            return(View(model));
        }
Пример #6
0
        public ActionResult Edit(int id, RepDetail model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new RepService();

            if (service.UpdateRep(model))
            {
                TempData["SaveResult"] = "Rep Details Successfully Updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Failed to Update Rep");
            return(View(model));
        }