public ActionResult ActionsList(int type) { CheckUserRole(false); ActionListModel model = new ActionListModel {Type = (ExportImportType)type}; AdminBl.SetModel(model); ViewBag.Title = "Список " + (model.Type == ExportImportType.Import ? "загрузок" : "выгрузок"); return View(model); }
public ActionResult ActionsList(ActionListModel model) { CheckUserRole(false); if (model.Type == ExportImportType.Import) { AdminBl.ImportFile(model); AdminBl.SetModel(model); } else AdminBl.ExportFile(model); if(!string.IsNullOrEmpty(model.Error)) ModelState.AddModelError(string.Empty,model.Error); //AdminBl.SetModel(model); ViewBag.Title = "Список " + (model.Type == ExportImportType.Import ? "загрузок" : "выгрузок"); return View(model); }
public void SetModel(ActionListModel model) { SetModelInternal(model,true); }
public void ImportFile(ActionListModel model) { ImportFileInternal(model); }
public void ExportFile(ActionListModel model) { try { ExportFileInternal(model); } finally { SetModelInternal(model,false); } }
protected void SetMonths(ActionListModel model,bool setSelection) { if (model.Type == ExportImportType.Export) { model.Monthes = TimesheetDao.GetTimesheetDates().ToList(). ConvertAll(x => new DateDto { Date = x, Name = x.ToString("MMMM") + " " + x.Year.ToString(), }); if(setSelection) model.Month = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); } else model.Monthes = new List<DateDto> { new DateDto {Date = DateTime.Today,Name = string.Empty}}; }
protected void SetModelInternal(ActionListModel model,bool setSelection) { model.Actions = ExportImportActionDao. LoadForTypeSorted(model.Type).ToList(). ConvertAll(x => new IdNameDto ( x.Id, x.Date.ToString()+ (x.Month.HasValue?" "+GetMonth(x.Month.Value):string.Empty) )); SetMonths(model, true); }