public void Edit(PoleViewModels model)
        {
            Pole pole = Repository.GetById(model.Id);

            pole = Mapper.ModelToData(pole, model);
            Repository.Save();
        }
        public void Add(PoleViewModels model)
        {
            Pole pole = new Pole();

            pole.Pole_ID = Guid.NewGuid();

            Repository.Add(Mapper.ModelToData(pole, model));
            Repository.Save();
        }
        public ActionResult Details(string id)
        {
            PoleViewModels model = Service.GetById(id);

            if (model == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            return(View(model));
        }
        public ActionResult CreateEdit(PoleViewModels model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(model.Id))
                {
                    Service.Add(model);
                }
                else
                {
                    Service.Edit(model);
                }

                return(RedirectToAction("Index"));
            }

            return(View("Create", model));
        }
示例#5
0
 public Pole ModelToData(Pole pole, PoleViewModels model)
 {
     pole.Name       = model.Name;
     pole.Manager_ID = new Guid(model.ManagerId);
     return(pole);
 }