Exemplo n.º 1
0
        public ActionResult CreateSuspension(SuspensionView suspensionInfo)
        {
            //Check that Suspension Info is Not Null
            if (suspensionInfo == null)
            {
                throw new ArgumentNullException(nameof(suspensionInfo));
            }

            //Validate Model
            if (!ModelState.IsValid)
            {
                var model = this.suspensionService.CreateSuspensionUpdatedView(suspensionInfo, string.Empty);
                return(View("CreateSuspension", model));
            }


            //Process The Suspension Information
            var processingMessage = suspensionService.ProcessSuspensionInfo(suspensionInfo);

            //Check if the Processing Message is Not Empty
            //If it is not empty, Means there is no error
            if (!string.IsNullOrEmpty(processingMessage))
            {
                var model = this.suspensionService.CreateSuspensionUpdatedView(suspensionInfo, processingMessage);
                return(this.View("CreateSuspension", model));
            }

            processingMessage = string.Format("New Suspension Record  Created", suspensionInfo.SuspensionId);

            return(this.RedirectToAction("SuspensionList", new { message = processingMessage }));
        }
Exemplo n.º 2
0
        public ActionResult EditSuspension(SuspensionView suspensionInfo)
        {
            if (suspensionInfo == null)
            {
                throw new ArgumentNullException(nameof(suspensionInfo));
            }

            if (!ModelState.IsValid)
            {
                var model = this.suspensionService.CreateSuspensionUpdatedView(suspensionInfo, "");

                return(View("EditSuspension", model));
            }

            var processingMessage = suspensionService.ProcessEditSuspensionInfo(suspensionInfo);

            if (!string.IsNullOrEmpty(processingMessage))
            {
                var model = this.suspensionService.CreateSuspensionUpdatedView(suspensionInfo, processingMessage);

                return(this.View("EditSuspension", model));
            }

            processingMessage = string.Format("{0} Updated", suspensionInfo.SuspensionId);

            return(this.RedirectToAction("SuspensionList", new { message = processingMessage }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="suspensionInfo"></param>
        /// <param name="companyCollection"></param>
        /// <param name="processingMessage"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">suspensionInfo</exception>
        public ISuspensionView CreateUpdatedSuspensionView(ISuspensionView suspensionInfo, int companyId, string processingMessage)
        {
            if (suspensionInfo == null)
            {
                throw new ArgumentNullException(nameof(suspensionInfo));
            }

            var trainingView = new SuspensionView
            {
                SuspensionId = suspensionInfo.SuspensionId,
                EmployeeId   = suspensionInfo.EmployeeId,
                QueryId      = suspensionInfo.QueryId,
                StartDate    = suspensionInfo.StartDate,
                EndDate      = suspensionInfo.EndDate,
                Percentage   = suspensionInfo.EmployeeId,
                IsActive     = suspensionInfo.IsActive,
                DateCreated  = suspensionInfo.DateCreated,
                CompanyId    = companyId
            };

            return(trainingView);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the suspension view.
        /// </summary>
        /// <param name="suspensionView">The suspension view.</param>
        /// <param name="companyId">The company identifier.</param>
        /// <param name="employeeCollection">The employee collection.</param>
        /// <param name="queryCollection">The query collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">companyId</exception>
        public ISuspensionView CreateSuspensionView(IList <ISuspension> suspensionView, int companyId, IList <IEmployee> employeeCollection, IList <IQuery> queryCollection)
        {
            //throw an exception if the companyCollection is null
            if (companyId <= 0)
            {
                throw new ArgumentNullException(nameof(companyId));
            }


            var employeeDDL = GetDropDownList.EmployeeListitems(employeeCollection, -1);
            var queryDDL    = GetDropDownList.QueryListItems(queryCollection, -1);

            var viewModel = new SuspensionView
            {
                //Assigning the drop down to the View model
                CompanyId        = companyId,
                EmployeeDropDown = employeeDDL,
                QueryDropDown    = queryDDL,
            };

            return(viewModel);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the edit suspension view.
        /// </summary>
        /// <param name="suspensionInfo">The suspension information.</param>
        /// <param name="companyInfo">The company information.</param>
        /// <param name="employeeCollection">The employee collection.</param>
        /// <param name="queryCollection">The query collection.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// suspensionInfo
        /// or
        /// employeeCollection
        /// or
        /// queryCollection
        /// </exception>
        public ISuspensionView CreateEditSuspensionView(ISuspension suspensionInfo, int companyId, IList <IEmployee> employeeCollection, IList <IQuery> queryCollection)
        {
            if (suspensionInfo == null)
            {
                throw new ArgumentNullException(nameof(suspensionInfo));
            }

            if (employeeCollection == null)
            {
                throw new ArgumentNullException(nameof(employeeCollection));
            }

            if (queryCollection == null)
            {
                throw new ArgumentNullException(nameof(queryCollection));
            }

            var employeeDDL = GetDropDownList.EmployeeListitems(employeeCollection, -1);
            var queryDDL    = GetDropDownList.QueryListItems(queryCollection, -1);

            var returnSuspension = new SuspensionView
            {
                SuspensionId     = suspensionInfo.SuspensionId,
                EmployeeId       = suspensionInfo.EmployeeId,
                QueryId          = suspensionInfo.QueryId,
                StartDate        = suspensionInfo.StartDate,
                EndDate          = suspensionInfo.EndDate,
                Percentage       = suspensionInfo.EmployeeId,
                IsActive         = suspensionInfo.IsActive,
                DateCreated      = suspensionInfo.DateCreated,
                CompanyId        = companyId,
                EmployeeDropDown = employeeDDL,
                QueryDropDown    = queryDDL,
                QueryName        = suspensionInfo.QueryName
            };

            return(returnSuspension);
        }