예제 #1
0
 public IEnumerable<Account> Items()
 {
     using (var context = new DataBaseContext())
     {
         return context.Accounts.ToList();
     }
 }
예제 #2
0
 public Account GetByEmail(string email)
 {
     using (var context = new DataBaseContext())
     {
         return context.Accounts.FirstOrDefault(account => account.Email.ToLower() == email.ToLower());
     }
 }
예제 #3
0
 public Account GetByUserName(string email)
 {
     using (var context = new DataBaseContext())
     {
         return context.Accounts.FirstOrDefault(account => account.UserName == email);
     }
 }
예제 #4
0
 public Account GetById(int id)
 {
     using (var context = new DataBaseContext())
     {
         return context.Accounts.FirstOrDefault(account => account.Id == id);
     }
 }
예제 #5
0
 public List<UserRating> GetAllRatings(int employeeId)
 {
     using (var context=new DataBaseContext())
     {
         return context.UserRatings.Where(userRating => userRating.RatingReceiverId == employeeId).ToList();
     }
 }
예제 #6
0
 public void ChangeOrderEmployee(int orderId, int? employeeId)
 {
     using (var context = new DataBaseContext())
     {
         context.Orders.FirstOrDefault(order => order.Id == orderId).EmployeeId = employeeId;
         context.SaveChanges();
     }
 }
예제 #7
0
 public void ChangeOrderStatus(int orderId, int newStatus)
 {
     using (var context = new DataBaseContext())
     {
         context.Orders.FirstOrDefault(order => order.Id == orderId).Status = newStatus;
         context.SaveChanges();
     }
 }
예제 #8
0
 public int GetPositiveRatingForUser(int userId)
 {
     using (var context = new DataBaseContext())
     {
         return
             context.UserRatings.Count(
                 userRating => (userRating.RatingReceiverId == userId && userRating.Rating));
     }
 }
예제 #9
0
 public void AddRaiting(UserRating userRating)
 {
     using (var context=new DataBaseContext())
     {
         userRating.CreatedTime = DateTime.UtcNow;
         context.UserRatings.Add(userRating);
         context.SaveChanges();
     }
 }
예제 #10
0
 public void AddMessage(Message message)
 {
     using (var context = new DataBaseContext())
     {
         message.CreatedTime = DateTime.UtcNow;
         context.Messages.Add(message);
         context.SaveChanges();
     }
 }
예제 #11
0
 public void Save(UserEvent userEvent)
 {
     using (var context = new DataBaseContext())
     {
         userEvent.CreatedTime = DateTime.UtcNow;
         context.UserEvents.Add(userEvent);
         context.SaveChanges();
     }
 }
예제 #12
0
 public void AddCommentToOrder(OrderComment orderComment)
 {
     using (var context = new DataBaseContext())
     {
         orderComment.CreatedTime = DateTime.UtcNow;
         context.OrderComments.Add(orderComment);
         context.SaveChanges();
     }
 }
예제 #13
0
 public void Create(Account account)
 {
     using (var context = new DataBaseContext())
     {
         account.CreatedTime = DateTime.UtcNow;
         context.Accounts.Add(account);
         context.SaveChanges();
     }
 }
예제 #14
0
 public void Create(Order order)
 {
     using (var context = new DataBaseContext())
     {
         order.CreatedTime = DateTime.UtcNow;
         order.Status = OrderStatus.Openned;
         context.Orders.Add(order);
         context.SaveChanges();
     }
 }
예제 #15
0
 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();
     }
 }
예제 #16
0
 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);
     }
 }
예제 #17
0
 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();
     }
 }
예제 #18
0
 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();
     }
 }
예제 #19
0
 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();
     }
 }
예제 #20
0
 public List<Order> Items()
 {
     using (var context = new DataBaseContext())
     {
         return context.Orders.Include("Creater").Include("OrderComments").OrderByDescending(order => order.CreatedTime).ToList();
     }
 }
예제 #21
0
 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();
     }
 }