示例#1
0
        public ActionResult ChangeIsRead(int id)
        {
            if (UserContext.User.Id == Dom.Common.UserId)
            {
                Registration registration = _registrationRepository.Get <Registration>(id);
                registration.IsRead = !registration.IsRead;
                _registrationRepository.UnitOfWork.SaveChanges();

                return(RedirectToAction(Mvc.Controller.Registration.List, Mvc.Controller.Registration.Name));
            }
            return(RedirectHome());
        }
示例#2
0
        private static bool GetTaskAndRegistration(SPWeb web, IRegistrationApprovalView view, string taskID, out Registration registration)
        {
            IRegistrationApprovalTaskRepository registrationApprovalTaskRepository = ServiceLocator.GetInstance().Get <IRegistrationApprovalTaskRepository>();
            RegistrationApprovalTask            registrationApprovalTask           = null;

            if (!String.IsNullOrEmpty(taskID))
            {
                int queryID;
                if (int.TryParse(taskID, out queryID))
                {
                    registrationApprovalTask = registrationApprovalTaskRepository.Get(queryID, web);
                }
            }

            if (registrationApprovalTask == null)
            {
                view.Message = "The Approval Task selected is not valid.";
                registration = null;
                return(false);
            }

            IRegistrationRepository registrationRepository = ServiceLocator.GetInstance().Get <IRegistrationRepository>();
            int registrationID = registrationApprovalTask.WorkflowItemId;

            registration = registrationRepository.Get(registrationID, web);
            if (registration == null)
            {
                view.Message = "The Registration associated with the selected Approval Task is not valid.";
                return(false);
            }

            return(true);
        }
        public async Task <IActionResult> Get()
        {
            var list = await _registrationRepository.Get();

            if (list.Any())
            {
                return(Ok(list));
            }
            else
            {
                return(NotFound());
            }
        }
示例#4
0
        /// <summary>
        /// Populates the SPWorkflowTaskProperties with Title and AssignedTo data.
        /// </summary>
        /// <param name="taskProperties">SPWorkflowTaskProperties to populate.</param>
        /// <param name="web">The SPWeb in the current workflow context.</param>
        /// <param name="workflowItem">The SPListItem that the workflow instance is associated with.</param>
        public void PopulateManagerApprovalTaskProperties(SPWorkflowTaskProperties taskProperties, SPWeb web, SPListItem workflowItem)
        {
            IHRManager hrManager = serviceLocator.Get <IHRManager>();
            IRegistrationRepository   registrationRepository   = serviceLocator.Get <IRegistrationRepository>();
            ITrainingCourseRepository trainingCourseRepository = serviceLocator.Get <ITrainingCourseRepository>();

            //get registration and training course related to this task.
            Registration   registration   = registrationRepository.Get(workflowItem.ID, web);
            TrainingCourse trainingCourse = trainingCourseRepository.Get(registration.CourseId, web);

            //get the user and manager related to this registration.
            SPUser user    = GetSPUser(web, registration.UserId);
            SPUser manager = GetSPUser(web, hrManager.GetManager(user.LoginName));

            taskProperties.AssignedTo = manager.LoginName;
            taskProperties.Title      = String.Format("Approve new registration request from {0} for {1}.", user.Name, trainingCourse.Code);
        }
示例#5
0
        private bool GetUserRegistration(SPWeb web, TrainingCourse course, string loginName, out SPUser user, out Registration registration)
        {
            bool success = false;

            user = web.SiteUsers[loginName];

            IRegistrationRepository registrationRepository = ServiceLocator.GetInstance().Get <IRegistrationRepository>();

            registration = registrationRepository.Get(course.Id, user.ID, web);

            if (registration == null)
            {
                success = true;
            }
            else
            {
                this._view.ContentMessage = string.Format("A registration request for this Course with the status of '{0}' has already been submitted by you.", registration.RegistrationStatus);
            }

            return(success);
        }
示例#6
0
        /// <summary>
        /// Charges the Accounting service for the cost of the course registration.
        /// </summary>
        /// <param name="web">The SPWeb in the current workflow context.</param>
        /// <param name="workflowItem">The SPListItem that the workflow instance is associated with.</param>
        public void ChargeAccounting(SPWeb web, SPListItem workflowItem)
        {
            IHRManager                hrManager                = serviceLocator.Get <IHRManager>();
            IAccountingManager        accountingManager        = serviceLocator.Get <IAccountingManager>();
            IRegistrationRepository   registrationRepository   = serviceLocator.Get <IRegistrationRepository>();
            ITrainingCourseRepository trainingCourseRepository = serviceLocator.Get <ITrainingCourseRepository>();

            //get registration and training course related to this task.
            Registration   registration   = registrationRepository.Get(workflowItem.ID, web);
            TrainingCourse trainingCourse = trainingCourseRepository.Get(registration.CourseId, web);

            //get the user related to this registration
            SPUser user = GetSPUser(web, registration.UserId);

            //construct the transaction related to this approved registration
            Transaction tran = new Transaction();

            tran.Amount      = trainingCourse.Cost;
            tran.CostCenter  = hrManager.GetCostCenter(user.LoginName);
            tran.Bucket      = trainingBucketString;
            tran.Description = String.Format("{0} training course registration by {1}.", trainingCourse.Title, user.Name);

            accountingManager.SaveTransaction(tran);
        }
示例#7
0
 public Registration Get(Contact contact)
 {
     return(_repository.Get(contact.Uri));
 }
示例#8
0
        public IList <RegistrationDto> GetRegistrations()
        {
            var registrations = _registrationRepository.Get();

            return(Mapper.Map <IList <RegistrationDto> >(registrations));
        }