Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            tblAuthor tblAuthor = _unitOfWork.Authors.Get(id);

            _unitOfWork.Authors.Remove(tblAuthor);
            _unitOfWork.Complete();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Edit(tblAuthor tblAuthor)
 {
     if (ModelState.IsValid)
     {
         _unitOfWork.Authors.Update(tblAuthor);
         _unitOfWork.Complete();
         return(RedirectToAction("Index"));
     }
     return(View(tblAuthor));
 }
 public void SaveAuthor(tblAuthor author)
 {
     if (author.AuthorId == 0)
     {
         db.tblAuthors.Add(author);
     }
     else
     {
         db.Entry(author).State = EntityState.Modified;
     }
     db.SaveChanges();
 }
Exemplo n.º 4
0
        public ActionResult Create(tblAuthor tblAuthor)
        {
            if (ModelState.IsValid)
            {
                tblAuthor.id = Guid.NewGuid();
                _unitOfWork.Authors.Add(tblAuthor);
                _unitOfWork.Complete();
                return(RedirectToAction("Index"));
            }

            return(View(tblAuthor));
        }
Exemplo n.º 5
0
        // GET: Authors/Delete/5
        public ActionResult Delete(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblAuthor tblAuthor = _unitOfWork.Authors.Get(id);

            if (tblAuthor == null)
            {
                return(HttpNotFound());
            }
            return(View(tblAuthor));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    AuthorEntity author = new AuthorEntity();
                    author = AF.GetAuthorByAuthorID(Convert.ToInt32(Request.QueryString["id"]));

                    txtAuthorName.Text      = author.AutherName;
                    txtEmail.Text           = author.AutherEmail;
                    txtContact.Text         = author.AutherConatct;
                    Session["AuthorEditId"] = author.AuthorId;
                    btnSaveAuthor.Text      = "Update";
                }
                if (Request.QueryString["did"] != null)
                {
                }
            }
        }