Example #1
0
        // GET: Author/Delete/5
        public ActionResult Delete(int id)
        {
            var author = _unitOfWork.Authors.Get(id);
            var model = new AuthorViewModel() {FirstName = author.FirstName, LastName = author.LastName};

            return PartialView("_DeletePartial", model);
        }
Example #2
0
        public ActionResult Create(AuthorViewModel model)
        {
            try
            {
                var author = new Author() {FirstName = model.FirstName, LastName = model.LastName};
                _unitOfWork.Authors.Add(author);
                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_CreateEditPartial");
            }
        }
Example #3
0
        public ActionResult Delete(int id, AuthorViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Authors.Get(id);

                _unitOfWork.Authors.Delete(existingRecord);
                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_DeletePartial");
            }
        }
Example #4
0
        public ActionResult Edit(int id, AuthorViewModel model)
        {
            try
            {
                var existingRecord = _unitOfWork.Authors.Get(id);
                existingRecord.FirstName = model.FirstName;
                existingRecord.LastName = model.LastName;

                _unitOfWork.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return PartialView("_CreateEditPartial");
            }
        }
Example #5
0
        // GET: Author/Edit/5
        public ActionResult Edit(int id)
        {
            var author = _unitOfWork.Authors.Get(id);
            var model = new AuthorViewModel() {Id = author.Id, FirstName = author.FirstName, LastName = author.LastName};

            return PartialView("_CreateEditPartial",model);
        }