public ActionResult PrintDeductionList(string beginDate,string endDate, int? departmentId, int? requestStatusId, int? typeId, string userName, int? sortBy, bool? sortDescending) { DeductionListModel model = new DeductionListModel { BeginDate = parseDateTime(beginDate), EndDate = parseDateTime(endDate), DepartmentId = departmentId.HasValue?departmentId.Value:0, RequestStatusId = requestStatusId.HasValue?requestStatusId.Value:0, TypeId = typeId.HasValue?typeId.Value:0, UserName = string.IsNullOrEmpty(userName)?string.Empty:Server.UrlDecode(userName), SortBy = sortBy.HasValue?sortBy.Value:0, SortDescending = sortDescending.HasValue?sortDescending.Value:new bool?(), }; RequestBl.SetDeductionListModel(model, !ValidateModel(model)); return View(model); }
protected bool ValidateModel(DeductionListModel model) { if (model.BeginDate.HasValue && model.EndDate.HasValue && model.BeginDate.Value > model.EndDate.Value) ModelState.AddModelError("BeginDate", "Дата в поле <Период с> не может быть больше даты в поле <по>."); return ModelState.IsValid; }
public ActionResult Index(DeductionListModel model) { RequestBl.SetDeductionListModel(model, !ValidateModel(model)); return View(model); }