Exemplo n.º 1
0
 public static Entity.Products FromProductModel(ProductModel context)
 {
     using (var database = new Entity.DataBaseModel())
     {
         var product = database.Products.FirstOrDefault(u => u.Id == context.Id);
         return(product);
     }
 }
Exemplo n.º 2
0
 public static Entity.Orders FromOrdersModel(OrdersModel context)
 {
     using (var database = new Entity.DataBaseModel())
     {
         var sale = database.Orders.FirstOrDefault(u => u.Id == context.Id);
         return(sale);
     }
 }
Exemplo n.º 3
0
 public static Entity.UserOfClient FromUserOfClientModel(UserOfClientModel context)
 {
     using (var database = new Entity.DataBaseModel())
     {
         var user = database.UserOfClient.FirstOrDefault(u => u.Id == context.Id);
         return(user);
     }
 }
Exemplo n.º 4
0
        public static OrdersModel FromOrdersModel(Entity.Orders context)
        {
            var database = new Entity.DataBaseModel();

            return(new OrdersModel
            {
                Id = context.Id,
                OrderName = context.OrderName,
                FirstName = context.Client.UserOfClient.FirstName,
                LastName = context.Client.UserOfClient.LastName,
                MiddleName = context.Client.UserOfClient.MiddleName,
                Price = context.ListOfProductsInOrder.Where(o => o.OrderId == context.Id).Select(o => o.Products).Sum(p => p.Price),
                Amount = context.ListOfProductsInOrder.Where(o => o.OrderId == context.Id).Select(o => o.Products).Count()
            });
            //var orderVM = new OrdersModel();
            //orderVM.Id = context.Id;
            //orderVM.OrderName = context.OrderName;
            //return orderVM;
        }