Exemple #1
0
 public bool InsertUser(UserDetail user)
 {
     using (MVCCRUDKNOCKOUTEntities dbEntities = new MVCCRUDKNOCKOUTEntities())
     {
         dbEntities.UserDetail.Add(user);
         dbEntities.SaveChanges();
         return(true);
     }
 }
Exemple #2
0
 public bool DeleteUser(int UserID)
 {
     using (MVCCRUDKNOCKOUTEntities dbEntities = new MVCCRUDKNOCKOUTEntities())
     {
         var deleteItem = dbEntities.UserDetail.FirstOrDefault(c => c.ID == UserID);
         if (deleteItem != null)
         {
             dbEntities.UserDetail.Remove(deleteItem);
             dbEntities.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #3
0
 public bool update(int id, GetAllUsersDTO user)
 {
     using (MVCCRUDKNOCKOUTEntities dbEntities = new MVCCRUDKNOCKOUTEntities())
     {
         var updateItem = dbEntities.UserDetail.FirstOrDefault(c => c.ID == id);
         if (updateItem != null)
         {
             updateItem.Address                 = user.Address;
             updateItem.Age                     = user.Age;
             updateItem.Name                    = user.Name;
             updateItem.PhoneNumber             = user.PhoneNumber;
             updateItem.Gender                  = user.Gender;
             dbEntities.Entry(updateItem).State = System.Data.Entity.EntityState.Modified;
             dbEntities.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }