public bool Save(User user) { try { var exists = Dbset.FirstOrDefault(x => x.Id == user.Id); if (exists != null) { exists.Password = exists.Password; exists.Name = user.Name; exists.LastName = user.LastName; exists.Email = user.Email; exists.CompanyId = user.CompanyId; exists.Profile = user.Profile; exists.CompanyId = user.CompanyId; Update(exists); } else { var passwordEncoded = StringExtension.RandomString(5, true).Encrypt(StringExtension.PassPhrase); user.Password = passwordEncoded; Create(user); } return(true); } catch (Exception e) { throw new Exception(e.Message, e); } }
public bool Save(Company model) { var exists = Dbset.FirstOrDefault(x => x.Id == model.Id); if (exists != null) { exists.Name = model.Name; Update(exists); } else { Create(model); } return(true); }
public void Reorder(int oldOrder, int newOrder, int userId) { var task = Dbset.FirstOrDefault(x => x.UserId == userId && x.IsArchived == false && x.Order == oldOrder); if (task == null) { throw new MyException("Task does not exist in the database."); } var tasksToReorder = (newOrder > oldOrder) ? Dbset.Where(x => x.UserId == userId && x.IsArchived == false && x.Order >= oldOrder && x.Order <= newOrder).ToList() : Dbset.Where(x => x.UserId == userId && x.IsArchived == false && x.Order <= oldOrder && x.Order >= newOrder).ToList(); foreach (var taskToReorder in tasksToReorder) { taskToReorder.Order = (newOrder > oldOrder) ? --taskToReorder.Order : ++taskToReorder.Order; _context.Entry(taskToReorder).State = EntityState.Modified; } task.Order = (byte?)newOrder; _context.Entry(task).State = EntityState.Modified; _context.SaveChanges(); }
public Company GetById(Guid id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public CellSetting GetSettingById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public ShipmentEntity GetSingle(Guid idShipment) { return(Dbset.FirstOrDefault(x => x.IdShipment == idShipment)); }
public UserProfileEntity GetSingle(string email) { return(Dbset.FirstOrDefault(x => x.UserName.ToLower() == email.ToLower())); }
public User GetByEmail(string email) { return(Dbset.FirstOrDefault(x => x.Email == email)); }
public Indicator Get(int id) { var record = Dbset.FirstOrDefault(r => r.IndicatorId == id); return(record); }
public CompanyIndicator Get(string ticker, int indicatorId) { var record = Dbset.FirstOrDefault(c => c.Ticker == ticker && c.IndicatorId == indicatorId); return(record); }
public Note Get(int id) { return(Dbset.FirstOrDefault(r => r.Id == id)); }
public Task Find(int id, int userId) { return(Dbset.FirstOrDefault(x => x.Id == id && x.UserId == userId)); }
public Task Find(int id, int userId, bool isArchived) { return(Dbset.FirstOrDefault(x => x.Id == id && x.UserId == userId && x.IsArchived == isArchived)); }
public Cell GetCellById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public Company Get(string ticker) { var record = Dbset.FirstOrDefault(r => r.Ticker == ticker); return(record); }
public Workspace Get(int id) { return(Dbset.FirstOrDefault(r => r.Id == id)); }
public Company GetByName(string name) { var currentLowerName = name.ToLower(); return(Dbset.FirstOrDefault(x => x.Name.ToLower() == currentLowerName)); }
public Product GetProductById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public PickyMessage GetById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public Story GetById(long id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public Category GetCategoryById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public ServiceEntity GetSingle(Guid idService) { return(Dbset.FirstOrDefault(x => x.IdService == idService)); }
public Review GetById(int id) { return(Dbset.FirstOrDefault(review => review.Id == id)); }
public Movie GetById(int id) { return(Dbset.FirstOrDefault(movie => movie.Id == id)); }
public User GetById(int id) { return(Dbset.FirstOrDefault(x => x.Id == id)); }
public PersonEntity GetSingle(Guid userId) { return(Dbset.FirstOrDefault(x => x.IdPerson == userId)); }
public UserProfileEntity GetSingle(int userId) { return(Dbset.FirstOrDefault(x => x.UserId == userId)); }
public PersonEntity GetSingle(string email) { var personEntity = Dbset.FirstOrDefault(q => q.UserName.ToLower().Equals(email.ToLower())); return(personEntity); }
public async Task <Car> GetById(Guid id) { var task = Task.Run(() => Dbset.FirstOrDefault(c => c.CarId == id)); return(await task); }
public Strategy Get(int id) { var record = Dbset.FirstOrDefault(r => r.StrategyId == id); return(record); }