コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: ModelFactory.cs プロジェクト: ramesh533/FlickSome
 public Reviewer Parse(Reviewer reviewer, ReviewerModel reviewerModel)
 {
     reviewer.Name = reviewerModel.Name;
     reviewer.SiteUrl = reviewerModel.SiteUrl;
     return reviewer;
 }