コード例 #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();
         }
     }
 }