public IEnumerable<Account> Items() { using (var context = new DataBaseContext()) { return context.Accounts.ToList(); } }
public Account GetByEmail(string email) { using (var context = new DataBaseContext()) { return context.Accounts.FirstOrDefault(account => account.Email.ToLower() == email.ToLower()); } }
public Account GetByUserName(string email) { using (var context = new DataBaseContext()) { return context.Accounts.FirstOrDefault(account => account.UserName == email); } }
public Account GetById(int id) { using (var context = new DataBaseContext()) { return context.Accounts.FirstOrDefault(account => account.Id == id); } }
public List<UserRating> GetAllRatings(int employeeId) { using (var context=new DataBaseContext()) { return context.UserRatings.Where(userRating => userRating.RatingReceiverId == employeeId).ToList(); } }
public void ChangeOrderEmployee(int orderId, int? employeeId) { using (var context = new DataBaseContext()) { context.Orders.FirstOrDefault(order => order.Id == orderId).EmployeeId = employeeId; context.SaveChanges(); } }
public void ChangeOrderStatus(int orderId, int newStatus) { using (var context = new DataBaseContext()) { context.Orders.FirstOrDefault(order => order.Id == orderId).Status = newStatus; context.SaveChanges(); } }
public int GetPositiveRatingForUser(int userId) { using (var context = new DataBaseContext()) { return context.UserRatings.Count( userRating => (userRating.RatingReceiverId == userId && userRating.Rating)); } }
public void AddRaiting(UserRating userRating) { using (var context=new DataBaseContext()) { userRating.CreatedTime = DateTime.UtcNow; context.UserRatings.Add(userRating); context.SaveChanges(); } }
public void AddMessage(Message message) { using (var context = new DataBaseContext()) { message.CreatedTime = DateTime.UtcNow; context.Messages.Add(message); context.SaveChanges(); } }
public void Save(UserEvent userEvent) { using (var context = new DataBaseContext()) { userEvent.CreatedTime = DateTime.UtcNow; context.UserEvents.Add(userEvent); context.SaveChanges(); } }
public void AddCommentToOrder(OrderComment orderComment) { using (var context = new DataBaseContext()) { orderComment.CreatedTime = DateTime.UtcNow; context.OrderComments.Add(orderComment); context.SaveChanges(); } }
public void Create(Account account) { using (var context = new DataBaseContext()) { account.CreatedTime = DateTime.UtcNow; context.Accounts.Add(account); context.SaveChanges(); } }
public void Create(Order order) { using (var context = new DataBaseContext()) { order.CreatedTime = DateTime.UtcNow; order.Status = OrderStatus.Openned; context.Orders.Add(order); context.SaveChanges(); } }
public IList<UserEvent> GetByUserId(int userId) { using (var context = new DataBaseContext()) { return context.UserEvents .Include("EventPublisher") .Where(evend => evend.EventSunscriberId == userId) .OrderByDescending(evend => evend.CreatedTime).ToList(); } }
public Order GetById(int id) { using (var context = new DataBaseContext()) { return context.Orders .Include("Creater") .Include("OrderComments") .Include("OrderComments.Author") .FirstOrDefault(order => order.Id == id); } }
public List<Message> GetByRecieverId(int recieverId) { using (var context = new DataBaseContext()) { return context.Messages .Include(message => message.Receiver) .Include(message => message.Sender) .Where(message => (message.ReceiverId == recieverId)).ToList(); } }
public List<Order> GetByStatusId(int statusId, int takeCount, int skipCount) { using (var context = new DataBaseContext()) { return context.Orders.Include("Creater") .Include("OrderComments.Author") .Where(ord => ord.Status == statusId) .OrderByDescending(order => order.CreatedTime) .Skip(skipCount) .Take(takeCount) .ToList(); } }
public List<Order> GetByKeyWords(IEnumerable<string> keyWords, int orderStatus, int takeCount, int skipCount) { using (var context = new DataBaseContext()) { return context .Orders .Include("Creater") .Include("OrderComments") .Include("OrderComments.Author") .Where(order => order.Status == orderStatus) .Where(order => keyWords.Any( keyWord => order.Title.ToLower().Contains(keyWord.ToLower()) || order.Content.Contains(keyWord.ToLower()))).OrderByDescending( order => order.CreatedTime).Skip(skipCount).Take(takeCount).ToList(); } }
public List<Order> Items() { using (var context = new DataBaseContext()) { return context.Orders.Include("Creater").Include("OrderComments").OrderByDescending(order => order.CreatedTime).ToList(); } }
public List<Order> GetByUserId(int id) { using (var context = new DataBaseContext()) { return context.Orders.Include("Creater").Include("OrderComments.Author").Where(order => order.CreaterId == id).ToList(); } }