/// <summary> /// Método para atualizar um usuário /// </summary> /// <param name="value"></param> /// <returns></returns> public bool Update(Model.User value) { try { User u = _context.Users.Find(value.Login); u.CPF = value.CPF; u.Password = value.Password; u.RG = value.RG; _context.Users.Attach(u); _context.Entry(u).State = EntityState.Modified; _context.SaveChanges(); return(true); } catch (Exception exception) { Log log = new Log { Date = DateTime.Now, Details = exception.Message, Message = "An exception occurred in method Update" }; _context.Logs.Add(log); _context.SaveChanges(); throw; } }
/// <summary> /// Método para atualizar uma passagem /// </summary> /// <param name="value"></param> /// <returns></returns> public Boolean Update(Model.Passage value) { try { Passage p = _context.Passages.Find(value.Number); p.Number = value.Number; p.ArrivalDate = value.ArrivalDate; p.DepartureDate = value.DepartureDate; p.IdUser = value.IdUser; p.Type = value.Type; _context.Passages.Attach(p); _context.Entry(p).State = EntityState.Modified; _context.SaveChanges(); return(true); } catch (Exception exception) { Log log = new Log { Date = DateTime.Now, Details = exception.Message, Message = "An exception occurred in method Update" }; _context.Logs.Add(log); _context.SaveChanges(); throw; } }