public ActionResult Edit()
        {
            Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
            List<customweek> weekcollection = UI.Utilities.DateTimeUtility.GetWeeks(DateTime.Now.Month, DateTime.Now.Year);
            customweek editingweek = new customweek();

            int year = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int week = 1;

            try
            {
                year = Convert.ToInt32(Request.QueryString["year"].ToString());
                month = Convert.ToInt32(Request.QueryString["month"].ToString());
                week = Convert.ToInt32(Request.QueryString["week"].ToString()) - 1;
                weekcollection = UI.Utilities.DateTimeUtility.GetWeeks(month, year);
                editingweek = weekcollection[week];
            }
            catch
            {
                foreach (customweek wk in weekcollection)
                {
                    if (wk.isCurrentweek)
                    {
                        editingweek = wk;
                    }
                }
            }
            userdashboardtimesheet usermonthlydashboardtimesheet = new userdashboardtimesheet();
            Business.ApplicationService.appuser dashboarduser = appclient.GetUserObject(Session["usertoken"].ToString());

            usermonthlydashboardtimesheet.User = dashboarduser;
            usermonthlydashboardtimesheet.timesheetmonth = UI.Utilities.DateTimeUtility.ToLongMonthName(editingweek.month);
            usermonthlydashboardtimesheet.timesheetsstartdate = editingweek.startdate.ToShortDateString();
            usermonthlydashboardtimesheet.timesheetenddate = editingweek.enddate.ToShortDateString();

            List<AppWeekTimeSheet> weektimesheetscollection = new List<AppWeekTimeSheet>();

            AppWeekTimeSheet dashboarddata = new AppWeekTimeSheet();

            dashboarddata.timesheetweek = editingweek;

            Business.ApplicationService.timesheet[] timesheets = appclient.Gettimesheets(Session["companyid"].ToString(), "", "", "", editingweek.startdate.ToString("yyyy-MM-dd hh:mm:ss"), editingweek.enddate.ToString("yyyy-MM-dd hh:mm:ss"));
            UI.testmodel.timesheet singletimesheet = new UI.testmodel.timesheet();
            if (timesheets.Length > 0)
            {
                UI.testmodel.timesheet objsheet = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.testmodel.timesheet>(timesheets[0].data);
                dashboarddata.timesheetid = timesheets[0].id;
                dashboarddata.weektimesheetdata = objsheet;
            }
            weektimesheetscollection.Add(dashboarddata);

            usermonthlydashboardtimesheet.weektimesheets = weektimesheetscollection;
            return View(usermonthlydashboardtimesheet);
        }
        public ActionResult Admindashboard()
        {
            admintimesheet adminmonthlydashboard = new admintimesheet();
            Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();

            adminmonthlydashboard.year = DateTime.Now.Year;
            adminmonthlydashboard.month = DateTime.Now.Month;
            adminmonthlydashboard.monthname = UI.Utilities.DateTimeUtility.ToLongMonthName(DateTime.Now.Month);
            adminmonthlydashboard.monthstarts = DateTime.Now;
            adminmonthlydashboard.monthends = DateTime.Now;
            adminmonthlydashboard.weekcollection = UI.Utilities.DateTimeUtility.GetWeeks(DateTime.Now.Month, DateTime.Now.Year);
            adminmonthlydashboard.numberofweeks = adminmonthlydashboard.weekcollection.Count;

            adminmonthlydashboard.usertimesheets = new List<userdashboardtimesheet>();

            List<Business.ApplicationService.appuser> consultants = new List<Business.ApplicationService.appuser>();
            consultants = appclient.GetAdmins(Session["companyid"].ToString(), "consultant", Session["usertoken"].ToString()).ToList();

            foreach (Business.ApplicationService.appuser consultant in consultants)
            {
                userdashboardtimesheet usermonthlydashboardtimesheet = new userdashboardtimesheet();

                //Retrieving Consultant Information
                usermonthlydashboardtimesheet.User = consultant;

                usermonthlydashboardtimesheet.timesheetmonth = UI.Utilities.DateTimeUtility.ToLongMonthName(DateTime.Now.Month);
                usermonthlydashboardtimesheet.timesheetsstartdate = "";
                usermonthlydashboardtimesheet.timesheetenddate = "";

                List<AppWeekTimeSheet> weektimesheetscollection = new List<AppWeekTimeSheet>();

                foreach (customweek custweek in adminmonthlydashboard.weekcollection)
                {
                    AppWeekTimeSheet dashboarddata = new AppWeekTimeSheet();

                    dashboarddata.timesheetweek = custweek;

                    Business.ApplicationService.timesheet[] timesheets = appclient.Gettimesheets(Session["companyid"].ToString(), consultant.Id, "", "", custweek.startdate.ToString("yyyy-MM-dd hh:mm:ss"), custweek.enddate.ToString("yyyy-MM-dd hh:mm:ss"));
                    UI.testmodel.timesheet singletimesheet = new UI.testmodel.timesheet();
                    if (timesheets.Length > 0)
                    {
                        UI.testmodel.timesheet objsheet = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.testmodel.timesheet>(timesheets[0].data);
                        dashboarddata.weektimesheetdata = objsheet;
                        dashboarddata.hasTimeSheet = true;
                    }
                    else
                    {
                        dashboarddata.hasTimeSheet = false;
                    }

                    weektimesheetscollection.Add(dashboarddata);
                }

                usermonthlydashboardtimesheet.weektimesheets = weektimesheetscollection;

                adminmonthlydashboard.usertimesheets.Add(usermonthlydashboardtimesheet);
            }

            return View(adminmonthlydashboard);
        }
        public ActionResult dashboard(FormCollection collection)
        {
            int selectedmonth = Convert.ToInt32(collection["selectedmonth"]);
            int selectedyear = Convert.ToInt32(collection["selectedyear"]);

            Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();

            userdashboardtimesheet usermonthlydashboardtimesheet = new userdashboardtimesheet();
            Business.ApplicationService.appuser dashboarduser = appclient.GetUserObject(Session["usertoken"].ToString());

            usermonthlydashboardtimesheet.User = dashboarduser;
            usermonthlydashboardtimesheet.timesheetmonth = UI.Utilities.DateTimeUtility.ToLongMonthName(selectedmonth);
            usermonthlydashboardtimesheet.timesheetsstartdate = "";
            usermonthlydashboardtimesheet.timesheetenddate = "";

            List<AppWeekTimeSheet> weektimesheetscollection = new List<AppWeekTimeSheet>();
            List<customweek> weekcollection = UI.Utilities.DateTimeUtility.GetWeeks(selectedmonth, selectedyear);

            foreach (customweek custweek in weekcollection)
            {
                AppWeekTimeSheet dashboarddata = new AppWeekTimeSheet();

                dashboarddata.timesheetweek = custweek;

                Business.ApplicationService.timesheet[] timesheets = appclient.Gettimesheets(Session["companyid"].ToString(), "", "", "", custweek.startdate.ToString("yyyy-MM-dd hh:mm:ss"), custweek.enddate.ToString("yyyy-MM-dd hh:mm:ss"));
                UI.testmodel.timesheet singletimesheet = new UI.testmodel.timesheet();
                if (timesheets.Length > 0)
                {
                    UI.testmodel.timesheet objsheet = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.testmodel.timesheet>(timesheets[0].data);
                    dashboarddata.weektimesheetdata = objsheet;
                }

                weektimesheetscollection.Add(dashboarddata);
            }

            usermonthlydashboardtimesheet.weektimesheets = weektimesheetscollection;

            return View(usermonthlydashboardtimesheet);
        }