コード例 #1
0
 public string Edit(Book book)
 {
     using (BookShoppeDBContext booksContext = new BookShoppeDBContext())
     {
         booksContext.Entry(book).State = EntityState.Modified;
         booksContext.SaveChanges();
         return(null);
     }
 }
コード例 #2
0
        public string EditUser(User user)
        {
            BookShoppeDBContext _context = new BookShoppeDBContext();

            _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateException e)
            {
                if (e.InnerException.InnerException.Message != null)
                {
                    return("The User Name should not be duplicated");
                }
                else
                {
                    return("Please fill out the form correctly and sumbit your values");
                }
            }
            return(null);
        }