Beispiel #1
0
        public ActionResult Create(CreateEditModelViewModel mvmCreate)
        {
            if (ModelState.IsValid)
            {
                Model model = Mapper.Map <CreateEditModelViewModel, Model>(mvmCreate);

                modelServices.Add(model);

                modelServices.Save();
                return(RedirectToAction("Index"));
            }

            return(View(mvmCreate));
        }
        public ActionResult Create(CreateEditModelViewModel mvmCreate)
        {
            if (ModelState.IsValid)
            {
                Model model = Mapper.Map<CreateEditModelViewModel, Model>(mvmCreate);

                modelServices.Add(model);

                modelServices.Save();
                return RedirectToAction("Index");
            }

            return View(mvmCreate);
        }
Beispiel #3
0
        public ActionResult Edit(CreateEditModelViewModel mvmEdit)
        {
            if (ModelState.IsValid)
            {
                //Mode

                Model model = Mapper.Map <CreateEditModelViewModel, Model>(mvmEdit);

                modelServices.Update(model);
                modelServices.Save();
                return(RedirectToAction("Index"));
            }

            return(View(mvmEdit));
        }
Beispiel #4
0
        // GET: /Model/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Model model = modelServices.GetByID(id.Value);

            if (model == null)
            {
                return(HttpNotFound());
            }

            CreateEditModelViewModel mvmEdit = Mapper.Map <Model, CreateEditModelViewModel>(model);

            return(View(mvmEdit));
        }
Beispiel #5
0
        //// GET: /Model/Details/5
        //public ActionResult Details(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Model model = modelRepo.GetByID(id.Value);
        //    if (model == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(model);
        //}

        // GET: /Model/Create
        public ActionResult Create()
        {
            CreateEditModelViewModel mvmCreate = Mapper.Map <Model, CreateEditModelViewModel>(new Model());

            return(View(mvmCreate));
        }
        public ActionResult Edit(CreateEditModelViewModel mvmEdit)
        {
            if (ModelState.IsValid)
            {
                //Mode

                Model model = Mapper.Map<CreateEditModelViewModel, Model>(mvmEdit);

                modelServices.Update(model);
                modelServices.Save();
                return RedirectToAction("Index");
            }

            return View(mvmEdit);
        }