public static user Update(user user) { try { user.roleName = RoleConstant.Member; user.status = "active"; user current = db.users.Find(user.userID); if (string.IsNullOrEmpty(user.password)) { user.password = current.password; } else { user.password = UserService.EncodePass(user.password); } user.userName = current.userName; db.Entry(current).CurrentValues.SetValues(user); db.SaveChanges(); } catch (Exception) { return(null); } return(user); }
/// <summary> /// /// </summary> /// <param name="moto"></param> /// <returns></returns> public static bool Update(Motorbike moto) { try { var currentMoto = entity.Motorbikes.Find(moto.Plate); entity.Entry(currentMoto).CurrentValues.SetValues(moto); entity.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public static bool Update(Customer customer) { try { QLNXeEntities entities = new QLNXeEntities(); var customers = entities.Customers.Find(customer.Id); entities.Entry(customers).CurrentValues.SetValues(customer); entities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Delete Ticket /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(Int64 id) { try { QLNXeEntities entities = new QLNXeEntities(); var ticket = entities.Tickets.First(ob => ob.TicketId == id); entities.Entry(ticket).State = EntityState.Deleted; entities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Update Ticket /// </summary> /// <param name="tk"></param> /// <returns></returns> public static bool Update(Ticket tk) { try { QLNXeEntities entities = new QLNXeEntities(); var ticket = entities.Tickets.Find(tk.TicketId); entities.Entry(ticket).CurrentValues.SetValues(tk); entities.SaveChanges(); return(true); } catch (Exception) { return(false); } }