Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 public Company GetById(Guid id)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id));
 }
Esempio n. 5
0
 public CellSetting GetSettingById(int id)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id));
 }
 public ShipmentEntity GetSingle(Guid idShipment)
 {
     return(Dbset.FirstOrDefault(x => x.IdShipment == idShipment));
 }
Esempio n. 7
0
 public UserProfileEntity GetSingle(string email)
 {
     return(Dbset.FirstOrDefault(x => x.UserName.ToLower() == email.ToLower()));
 }
Esempio n. 8
0
 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);
        }
Esempio n. 11
0
 public Note Get(int id)
 {
     return(Dbset.FirstOrDefault(r => r.Id == id));
 }
Esempio n. 12
0
 public Task Find(int id, int userId)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id && x.UserId == userId));
 }
Esempio n. 13
0
 public Task Find(int id, int userId, bool isArchived)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id && x.UserId == userId && x.IsArchived == isArchived));
 }
Esempio n. 14
0
 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));
 }
Esempio n. 17
0
        public Company GetByName(string name)
        {
            var currentLowerName = name.ToLower();

            return(Dbset.FirstOrDefault(x => x.Name.ToLower() == currentLowerName));
        }
Esempio n. 18
0
 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));
 }
Esempio n. 21
0
 public Category GetCategoryById(int id)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id));
 }
 public ServiceEntity GetSingle(Guid idService)
 {
     return(Dbset.FirstOrDefault(x => x.IdService == idService));
 }
Esempio n. 23
0
 public Review GetById(int id)
 {
     return(Dbset.FirstOrDefault(review => review.Id == id));
 }
Esempio n. 24
0
 public Movie GetById(int id)
 {
     return(Dbset.FirstOrDefault(movie => movie.Id == id));
 }
Esempio n. 25
0
 public User GetById(int id)
 {
     return(Dbset.FirstOrDefault(x => x.Id == id));
 }
 public PersonEntity GetSingle(Guid userId)
 {
     return(Dbset.FirstOrDefault(x => x.IdPerson == userId));
 }
Esempio n. 27
0
 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);
        }
Esempio n. 29
0
        public async Task <Car> GetById(Guid id)
        {
            var task = Task.Run(() => Dbset.FirstOrDefault(c => c.CarId == id));

            return(await task);
        }
Esempio n. 30
0
        public Strategy Get(int id)
        {
            var record = Dbset.FirstOrDefault(r => r.StrategyId == id);

            return(record);
        }