public ActionResult Edit(int id) { BreakDataAccess breakDataAccess = new BreakDataAccess(); BreakModel model = breakDataAccess.Read(id); return(View(model)); }
private List <ScheduleSlots> GetExistedScheduledPropertySlots(long schedId) { var probRes = _appDbExtContext.ScheduleProperties.Where(x => x.ScheduleId == schedId).ToList(); List <ScheduleSlots> existSlots = new List <ScheduleSlots>(); foreach (var propItem in probRes) { var propResourceId = _appDbExtContext.Schedule.FirstOrDefault(x => x.Id == propItem.ScheduleId && x.RecordState == RecordState.N).ResourceId; switch ((SchedulePropertyTypeModel)propItem.ModelEnumId) { case SchedulePropertyTypeModel.Break: var tmpBM = new BreakModel(); tmpBM.FromJson(propItem.Value); tmpBM.ResourceId = propResourceId; tmpBM.ScheduleTimeId = propItem.ScheduleId; existSlots.Add(tmpBM.ToSlot()); break; case SchedulePropertyTypeModel.Vocation: var tmpVM = new VacationModel(); tmpVM.FromJson(propItem.Value); tmpVM.ScheduleTimeId = propItem.ScheduleId; tmpVM.ResourceId = propResourceId; existSlots.Add(tmpVM.ToSlot()); break; default: break; } } return(existSlots); }
public async Task <ActionResult> Register(BreakModel model) { if (ModelState.IsValid) { BreakDataAccess breakDataAccess = new BreakDataAccess(); breakDataAccess.Create(model); return(RedirectToAction("List", "Break")); } // If we got this far, something failed, redisplay form return(View(model)); }
public void CreateTest() { BreakModel breakModel = new BreakModel(); breakModel.Brand = "Brembo"; breakModel.Name = "Brembo"; breakModel.Size = "400 mm"; breakModel.Type = "Racing"; BreakDataAccess breakDataAccess = new BreakDataAccess(); breakDataAccess.Create(breakModel); Assert.IsNotNull(breakModel); }
public void DeleteTest() { BreakDataAccess breakDataAccess = new BreakDataAccess(); List <BreakModel> breakList = breakDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (breakList == null || breakList.Count == 0) { Assert.Fail(); } BreakModel model = breakList[0]; breakDataAccess.Delete(model.Id); model = breakDataAccess.Read(model.Id); Assert.IsNull(model); }
public void EditTest() { BreakDataAccess breakDataAccess = new BreakDataAccess(); List <BreakModel> breakList = breakDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (breakList == null || breakList.Count == 0) { Assert.Fail(); } string newName = "New Name"; BreakModel model = breakList[0]; model.Name = newName; breakDataAccess.Update(model); model = breakDataAccess.Read(model.Id); Assert.AreEqual(newName, model.Name); }