Ejemplo n.º 1
0
        /// <summary>
        /// Function to retrieve index page.
        /// </summary>
        /// <returns>Index page</returns>
        public ActionResult Index()
        {
            this.AddBreadcrumbItem(Resources.Timesheet, Url.TimesheetAction());
            var model = new TimesheetPresenter();
            model.WorkDetail = new WorkDetail();
            model.WorkDetail.Project = new Project();
            model.WorkDetail.Date = this.timesheetService.RetrieveApplicableDate(true, DateTimeHelper.RetrieveCurrentDateTime(), SessionData.Instance.UserInfo.Developer.DeveloperID);

            var clients = this.lookupService.RetrieveClients(null, false, SessionData.Instance.UserInfo.Developer.DeveloperID);
            var projects = this.lookupService.RetrieveProjects(null, null, false, null, SessionData.Instance.UserInfo.Developer.DeveloperID);

            model.SortedListItem = this.timesheetService.OrderClientsAndProjects(clients, projects, SessionData.Instance.UserInfo.Developer.DeveloperID, model.WorkDetail.Date);

            model.AssignClients(clients.Sort());
            model.AssignParentProjects(projects.Sort());
            model.Projects.ForEach(p => { p.ProjectName = p.ProjectFullName; });

            model.AssignWorkCategories(this.lookupService.RetrieveWorkCategories(null, false, SessionData.Instance.UserInfo.Developer.DeveloperID));
            model.AssignWorkDetailList(this.timesheetService.RetrieveList(model.WorkDetail.Date, SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
            model.TotalTaskHour = model.WorkDetails.Sum(w => w.Hours);
            model.LastWorkDetail = this.timesheetService.RetrieveLastEntry(SessionData.Instance.UserInfo.Developer.DeveloperID);
            return this.View(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the feature.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="projectId">The project identifier.</param>
        /// <returns>feature list</returns>
        public ActionResult GetFeature(TimesheetPresenter presenter, string projectId)
        {
            if (presenter != null)
            {
                presenter.AssignFeatures(this.lookupService.RetrieveProjectFeatures(Convert.ToInt32(projectId, CultureInfo.CurrentCulture), SessionData.Instance.UserInfo.Developer.DeveloperID));
                return this.Json(presenter.Features);
            }

            return this.Json(string.Empty);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the client identifier.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="projectId">The project identifier.</param>
        /// <returns>client id</returns>
        public ActionResult GetClientId(TimesheetPresenter presenter, string projectId)
        {
            if (presenter == null || presenter.Projects == null || string.IsNullOrEmpty(projectId))
            {
                return this.Json(string.Empty);
            }

            if (Convert.ToInt32(projectId, CultureInfo.CurrentCulture) == DefaultId)
            {
                return this.Json(string.Empty);
            }

            var projects = presenter.Projects.FirstOrDefault(project => project.ProjectID == Convert.ToInt32(projectId, CultureInfo.CurrentCulture));
            if (projects != null)
            {
                return this.Json(projects.ClientID);
            }

            return this.Json(string.Empty);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Works the detail by identifier.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <returns>return project list</returns>
        public ActionResult GetProjectList(TimesheetPresenter presenter, string clientId)
        {
            if (presenter == null || presenter.Projects == null || string.IsNullOrEmpty(clientId))
            {
                return this.Json(string.Empty);
            }

            if (Convert.ToInt32(clientId, CultureInfo.CurrentCulture) == DefaultId)
            {
                return this.Json(presenter.Projects);
            }

            var projects = presenter.Projects.Where(project => project.ClientID == Convert.ToInt32(clientId, CultureInfo.CurrentCulture)).Select(p => { p.ProjectName = p.ProjectFullName; return p; }).ToList();

            if (projects.Count > 0)
            {
                return this.Json(projects);
            }

            return this.Json(string.Empty);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retrieves the work detail by identifier.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="workDetailId">The work detail identifier.</param>
        /// <returns>work detail</returns>
        public ActionResult WorkDetailById(TimesheetPresenter presenter, string workDetailId)
        {
            if (presenter != null)
            {
                presenter.WorkDetail = this.timesheetService.RetrieveById(Convert.ToInt32(workDetailId, CultureInfo.CurrentCulture));
                presenter.WorkingDate = presenter.WorkDetail.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
                return this.Json(presenter);
            }

            return this.Json(string.Empty);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Retrieves the work detail list.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="selectedDate">The selected date.</param>
        /// <returns>work detail list</returns>
        public ActionResult WorkDetails(TimesheetPresenter presenter, string selectedDate)
        {
            if (presenter != null)
            {
                if (SessionData.Instance.UserInfo != null && SessionData.Instance.UserInfo.Developer != null)
                {
                    presenter.AssignWorkDetailList(this.timesheetService.RetrieveList(Convert.ToDateTime(selectedDate, CultureInfo.CurrentCulture), SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
                    presenter.TotalTaskHour = presenter.WorkDetails.Sum(w => w.Hours);
                }
            }

            return this.PartialView(WorkDetailsPartialView, presenter);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Deletes the specified presenter.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="workDetailId">The work detail identifier.</param>
        /// <returns>void list</returns>
        public ActionResult Delete(TimesheetPresenter presenter, string workDetailId)
        {
            if (presenter != null)
            {
                this.timesheetService.Delete(Convert.ToInt32(workDetailId, CultureInfo.CurrentCulture));
            }

            return this.Json(string.Empty);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Inserts the or update.
        /// </summary>
        /// <param name="presenter">The presenter.</param>
        /// <param name="workDetailId">The work detail identifier.</param>
        /// <returns>work detail</returns>
        public ActionResult InsertOrUpdate(TimesheetPresenter presenter, string workDetailId)
        {
            if (presenter != null && presenter.WorkDetail != null)
            {
                if (SessionData.Instance.UserInfo != null && SessionData.Instance.UserInfo.Developer != null)
                {
                    presenter.WorkDetail.DeveloperID = SessionData.Instance.UserInfo.Developer.DeveloperID;
                }

                if (presenter.WorkDetail.FeatureID == DefaultId)
                {
                    presenter.WorkDetail.FeatureID = null;
                }

                presenter.WorkDetail.WorkDetailID = Convert.ToInt32(workDetailId, CultureInfo.CurrentCulture);
                presenter.AssignWorkDetailList(this.timesheetService.RetrieveList(Convert.ToDateTime(presenter.WorkDetail.Date, CultureInfo.CurrentCulture), SessionData.Instance.UserInfo.Developer.DeveloperID, SessionData.Instance.UserInfo.Developer.DeveloperID));
                presenter.TotalTaskHour = presenter.WorkDetails.Sum(w => w.Hours);
                presenter.TotalTaskHour = presenter.TotalTaskHour + presenter.WorkDetail.HoursReported;
                if (presenter.TotalTaskHour <= 24)
                {
                    this.timesheetService.InsertOrUpdate(presenter.WorkDetail, ApplicationType.Website);
                    return this.Json(presenter);
                }
            }

            return this.Json(presenter);
        }