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(); } }
// 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(); } } }