public ActionResult Index(CalendarListModel model)
        {
            if (model.SetOfBooks == null)
            {
                model.SetOfBooks = sobService
                    .GetByCompanyId(AuthenticationHelper.User.CompanyId)
                    .Select(x => new SelectListItem
                    {
                        Text = x.Name,
                        Value = x.Id.ToString()
                    }).ToList();
            }

            if (model.SOBId != 0 || model.SetOfBooks != null)
            {
                model.Calendars = getCalendarList(model);
            }

            return View(model);
        }
 private List<CalendarViewModel> getCalendarList(CalendarListModel model)
 {
     return service.GetAll(AuthenticationHelper.User.CompanyId, model.SOBId != 0 ? model.SOBId : Convert.ToInt64(model.SetOfBooks.First().Value), model.SearchText, true, model.Page, model.SortColumn, model.SortDirection)
         .Select(x => new CalendarViewModel(x)).ToList();
 }
 public ActionResult GetCalendarList(long sobId)
 {
     CalendarListModel model = new CalendarListModel();
     model.SOBId = sobId;
     model.Calendars = getCalendarList(model);
     return PartialView("_List", model);
 }