// Create public bool CreateCase(CaseCreate model) { Case entity = new Case { Name = model.Name, Manufacturer = model.Manufacturer, Color = model.Color, PowerSupply = model.PowerSupply, Type = model.Type, SidePanelWindow = model.SidePanelWindow, PowerSupplyShroud = model.PowerSupplyShroud, FrontPanelUSB = model.FrontPanelUSB, MotherboardFormFactor = model.MotherboardFormFactor, External52Bay = model.External52Bay, External35Bay = model.External35Bay, Internal35Bay = model.Internal35Bay, Internal25Bay = model.Internal25Bay, FullHeightExpansionSlots = model.FullHeightExpansionSlots, HalfHeightExpansionSlots = model.HalfHeightExpansionSlots, IsAvailable = model.IsAvailable }; _db.Cases.Add(entity); return(_db.SaveChanges() == 1); }
public ActionResult Create(CaseCreate Case) { var service = new CaseService(); if (ModelState.IsValid) { service.CreateCase(Case); return(RedirectToAction("Index")); } return(View(Case)); }
public IHttpActionResult Post(CaseCreate currentCase) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCaseService(); if (!service.CreateCase(currentCase)) { return(InternalServerError()); } return(Ok()); }
public bool CreateCase(CaseCreate model) { var entity = new Case() { OwnerId = _userId, DateOfIncident = model.DateOfIncident, SuspectId = model.SuspectId, CrimeId = model.CrimeId, BadgeId = model.BadgeId }; using (var ctx = new ApplicationDbContext()) { ctx.Cases.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateCase(CaseCreate model) { var entity = new Case() { UserId = _userId, Title = model.Title, Summary = model.Summary, HouseControl = model.HouseControl, SenateControl = model.SenateControl, CaseYear = model.CaseYear, CreatedUTC = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Cases.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(CaseCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateCaseService(); if (service.CreateCase(model)) { TempData["SaveResult"] = "Case has been added to our database."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Case could not be added, please confirm all necessary information has been entered."); return(View(model)); }