Exemplo n.º 1
0
        public ActionResult Edit(int id, ReviewerModel reviewerModel)
        {
            if (ModelState.IsValid)
            {
                Reviewer reviewer;

                if (id == default(int))
                {
                    reviewer = ModelFactoryInstance.Parse(new Reviewer(), reviewerModel);
                    reviewer.State = ObjectState.Added;
                    _reviewerRepo.Insert(reviewer);
                }
                else
                {
                    reviewer = _reviewerRepo.FindById(id);
                    reviewer = ModelFactoryInstance.Parse(reviewer, reviewerModel);
                    reviewer.State = ObjectState.Modified;
                    _reviewerRepo.Update(reviewer);
                }
                _unitOfWork.Save();
                return RedirectToAction("Index");
            }

            return View(reviewerModel);
        }
Exemplo n.º 2
0
        public ActionResult Edit(int? id)
        {
            ReviewerModel reviewerModel = null;

            if (id != null)
            {
                var reviewer = _reviewerRepo.FindById(id);

                if (reviewer != null)
                {
                    reviewerModel = ModelFactoryInstance.Create(reviewer);
                }
            }

            if (reviewerModel == null)
            {
                reviewerModel = new ReviewerModel();
            }

            return View(reviewerModel);
        }
Exemplo n.º 3
0
 public Reviewer Parse(Reviewer reviewer, ReviewerModel reviewerModel)
 {
     reviewer.Name = reviewerModel.Name;
     reviewer.SiteUrl = reviewerModel.SiteUrl;
     return reviewer;
 }