Manager action (full code)

Manager action (full code)

public ActionResult Manager()
{
            var context = new TasksDataContext();
            var scheduler = new DHXScheduler(this);
 
    #region check rights
            if (!RoleIs("Manager"))
                return RedirectToAction("Index", "System");
    #endregion
 
    #region configuration
 
            scheduler.Config.first_hour = 8;
            scheduler.Config.last_hour = 17;
            scheduler.Config.time_step = 30;
            scheduler.Config.full_day = true;
    #endregion
 
    #region views configuration
            scheduler.Views.Clear();
            scheduler.Views.Add(new WeekView());
            var units = new UnitsView("staff", "owner_id");
            units.Label = "Staff";
 
            var staff = from usr in context.aspnet_Users
                        join link in context.aspnet_UsersInRoles on usr.UserId equals link.UserId
                        join role in context.aspnet_Roles on link.RoleId equals role.RoleId
                        where role.RoleName == "Employee"
                        select new { key = usr.UserId, label = usr.UserName };
 
 
            units.AddOptions(staff);           
            scheduler.Views.Add(units);
            scheduler.InitialView = units.Name;
    #endregion
 
    #region lightbox configuration
            var text = new LightboxText("text", "Task");
            text.Height = 20;
            text.Focus = true;
            scheduler.Lightbox.Add(text);
 
            var descritpion = new LightboxText("details", "Details");
            descritpion.Height = 80;
            scheduler.Lightbox.Add(descritpion);
 
            var status = new LightboxSelect("status_id", "Status");
            status.AddOptions(context.Statuses);
 
            scheduler.Lightbox.Add(new LightboxTime("time"));
            scheduler.Lightbox.Add(status);
     #endregion      
 
     #region data      
            scheduler.EnableDataprocessor = true;
            scheduler.LoadData = true;
            scheduler.Data.Loader.PreventCache();
            scheduler.Data.DataProcessor.UpdateFieldsAfterSave = true;
            scheduler.InitialDate = new DateTime(2011, 10, 7);
     #endregion
 
            return View(scheduler);
}

comments powered by Disqus