private void SetShiftList() { IShiftService ss = new ShiftService(Settings.Default.db); List <Shift> jt = ss.All(); List <SelectListItem> select = new List <SelectListItem>(); select.Add(new SelectListItem { Text = "", Value = "" }); foreach (var it in jt) { select.Add(new SelectListItem { Text = it.name, Value = it.code.ToString(), Selected = false }); } ViewData["shiftList"] = select; }
public async void All() { var mock = new ServiceMockFacade <IShiftRepository>(); var records = new List <Shift>(); records.Add(new Shift()); mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records)); var service = new ShiftService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.ShiftModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLShiftMapperMock, mock.DALMapperMockFactory.DALShiftMapperMock, mock.BOLMapperMockFactory.BOLEmployeeDepartmentHistoryMapperMock, mock.DALMapperMockFactory.DALEmployeeDepartmentHistoryMapperMock); List <ApiShiftResponseModel> response = await service.All(); response.Should().HaveCount(1); mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
//• 名称(输入,不可空,唯一) //• 代码(输入,不可空,唯一) //• 开始时间(选择,时间,不可空,如06:00) //• 班次类型(选择,不可空,选项包含:今日/次日,默认今日) //• 截止时间(选择,时间,不可空,如06:00) //• 备注(输入,可空) public ResultMessage DoValidation(Shift model) { ResultMessage msg = new ResultMessage(); if (string.IsNullOrEmpty(model.name)) { msg.Success = false; msg.Content = "名称不能为空"; return(msg); } if (string.IsNullOrEmpty(model.code)) { msg.Success = false; msg.Content = "代码不能为空"; return(msg); } if (model.startAt.ToString() == "00:00:00") { msg.Success = false; msg.Content = "开始时间不能为空"; return(msg); } if (model.endAt.ToString() == "00:00:00") { msg.Success = false; msg.Content = "截止时间不能为空"; return(msg); } if (string.IsNullOrEmpty(model.shiftType.ToString()) || model.shiftType == 0) { msg.Success = false; msg.Content = "班次类型不能为空"; return(msg); } IShiftService cs = new ShiftService(Settings.Default.db); List <Shift> shift = cs.All(); if (model.id <= 0) { bool isRecordExists = shift.Where(p => p.code == model.code && p.name == model.name).ToList().Count() > 0; if (isRecordExists) { msg.Success = false; msg.Content = "数据已经存在!"; return(msg); } } else { bool isRecordExists = shift.Where(p => p.code == model.code && p.name == model.name && p.id != model.id).ToList().Count() > 0; if (isRecordExists) { msg.Success = false; msg.Content = "数据已经存在!"; return(msg); } } return(new ResultMessage() { Success = true, Content = "" }); }