Пример #1
0
        public static void insertRequirment(RequirementModel model)
        {
            DateTime?date = null;

            if (model.YearOfMade != null)
            {
                date = new DateTime(model.YearOfMade.GetValueOrDefault(), 1, 1);
            }

            using (AutorepairEntities context =
                       new AutorepairEntities())
            {
                context.Requirments.Add(new Requirment
                {
                    RequirmentsFirstName            = model.FirstName,
                    RequirmentsLastName             = model.LastName,
                    RequirmentsEmail                = model.Email,
                    RequirmentsBrand                = model.Brand,
                    RequirmentsYearOfMade           = date,
                    RequirmentsEngineCapacity       = model.EngineCapacity,
                    RequirmentsTypeOfEngine         = model.TypeOfEngine,
                    RequirmentsDescriptionOfProblem = model.DescriptionOfProblem,
                    RequirmentsStatus               = "NEW"
                }
                                        );

                context.SaveChanges();
            }
        }
Пример #2
0
 // Update state of Requirment - depend on ID
 public static void updateRequirment(int id, string status)
 {
     using (AutorepairEntities context =
                new AutorepairEntities())
     {
         var result = context.Requirments.SingleOrDefault(b => b.RequirmentsID == id);
         if (result != null)
         {
             result.RequirmentsStatus = status;
             context.SaveChanges();
         }
     }
 }
Пример #3
0
 //Async load of categorz
 public static async Task <List <CategoryDO> > GetCategoriesAsync()
 {
     using (AutorepairEntities context =
                new AutorepairEntities())
     {
         return(await context.Categories
                .Select(x => new CategoryDO()
         {
             CategoryID = x.CategoryID,
             CategoryShortCut = x.CategoryShortCut,
             CategoryName = x.CategoryName
         })
                .ToListAsync());
     }
 }
Пример #4
0
 // Load for category by name
 public static List <CategoryDO> GetCategory(string nameOfCategory)
 {
     using (AutorepairEntities context =
                new AutorepairEntities())
     {
         return(context.Categories
                .Select(x => new CategoryDO()
         {
             CategoryID = x.CategoryID,
             CategoryShortCut = x.CategoryShortCut,
             CategoryName = x.CategoryName
         })
                .Where(x => x.CategoryShortCut.Equals(nameOfCategory))
                .ToList());
     }
 }
Пример #5
0
 // Insert Requirment from Contact Us form
 public static async Task <List <RequirmentDO> > GetRequirmentAsync()
 {
     using (AutorepairEntities context =
                new AutorepairEntities())
     {
         return(await context.Requirments
                .Select(x => new RequirmentDO()
         {
             RequirmentsID = x.RequirmentsID,
             RequirmentsFirstName = x.RequirmentsFirstName,
             RequirmentsLastName = x.RequirmentsLastName,
             RequirmentsEmail = x.RequirmentsEmail,
             RequirmentsBrand = x.RequirmentsBrand,
             RequirmentsYearOfMade = x.RequirmentsYearOfMade,
             RequirmentsEngineCapacity = x.RequirmentsEngineCapacity,
             RequirmentsTypeOfEngine = x.RequirmentsTypeOfEngine,
             RequirmentsDescriptionOfProblem = x.RequirmentsDescriptionOfProblem,
             RequirmentsStatus = x.RequirmentsStatus
         })
                .ToListAsync());
     }
 }
Пример #6
0
        // Get product  depend on Categories
        public static List <ProductDO> GetProducts(
            List <CategoryDO> categories)
        {
            List <int> CategoriesID = new List <int>();

            foreach (CategoryDO category in categories)
            {
                CategoriesID.Add(category.CategoryID);
            }

            using (AutorepairEntities context =
                       new AutorepairEntities())
            {
                return(context.Products
                       .Where(x => CategoriesID.Contains(x.CategoryID))
                       .Select(x => new ProductDO()
                {
                    ProductID = x.ProductID,
                    ProductName = x.ProductName
                })
                       .ToList());
            }
        }