Ejemplo n.º 1
0
 public void Delete(T item)
 {
     if (_context.Entry(item).State == EntityState.Detached)
     {
         _dbSet.Attach(item);
     }
     _dbSet.Remove(item);
     _context.SaveChanges();
 }
Ejemplo n.º 2
0
        public ActionResult AuthorsEdit(
            [Bind(Include = "AuthorID,Surname,FirstName,CREPCCode,ORCID")] AuthorVievModel authorViewModel)
        {
            if (ModelState.IsValid)
            {
                Author author = dbAuthors.Authors.Find(authorViewModel.AuthorID);

                author.Surname   = authorViewModel.Surname;
                author.FirstName = authorViewModel.FirstName;
                author.CREPCCode = authorViewModel.CREPCCode;
                author.ORCID     = authorViewModel.ORCID;

                author.DateModified   = DateTime.Now;
                author.UserModifiedID = Guid.Parse(User.Identity.GetUserId());

                dbAuthors.Entry(author).State = EntityState.Modified;
                dbAuthors.SaveChanges();
                return(RedirectToAction("AuthorsIndex"));
            }
            return(View(authorViewModel));
        }