public ActionResult Add()
        {
            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;
                    }
                }
            }

            return(View(editingweek));
        }
        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));
        }