コード例 #1
0
        public async Task <IChangeStatusModel> AssignsMembersGroup(INewDayAssignModel model)
        {
            IChangeStatusModel moveToStatusResultModel = new ChangeStatusModel();

            DayAssign dayAssign = await CreateOrGetDayAssign(model);

            try
            {
                if (model.IsUnassignedAll)
                {
                    await jobStatusService.Pending(model.DayAssignId.Value, dayAssign.StatusId);
                }
                else if (dayAssign.StatusId != JobStatus.Assigned && model.TeamLeadId.HasValue)
                {
                    await jobStatusService.Assigned(dayAssign.Id, dayAssign.StatusId);
                }
                else if (dayAssign.StatusId != JobStatus.Opened && !model.TeamLeadId.HasValue)
                {
                    await jobStatusService.Opened(dayAssign.Id, dayAssign.StatusId);
                }

                model.Id = dayAssign.Id;
                await messageBus.Publish(model.Map <ChangeDayAssignMembersComand>());

                moveToStatusResultModel.IsSuccessful = true;
            }
            catch (NotImplementedException)
            {
                moveToStatusResultModel.IsSuccessful = false;
            }

            moveToStatusResultModel.DayAssignId = dayAssign.Id;
            return(moveToStatusResultModel);
        }
コード例 #2
0
        public async Task AssignEmployees(MemberAssignModel model)
        {
            IDayAssign dayAssign   = GetDayAssign(model.DayAssignId);
            var        currentUser = memberService.GetCurrentUser();

            //Janitor can create task only for himself
            if (currentUser.CurrentRole == RoleType.Janitor)
            {
                model.UserIdList = new List <Guid> {
                    currentUser.MemberId
                };
                model.TeamLeadId           = currentUser.MemberId;
                model.GroupId              = null;
                model.IsAssignedToAllUsers = false;
            }

            var memberModel = new ChangeDayAssignMembersComand(dayAssign.Id.ToString())
            {
                UserIdList           = model.UserIdList,
                GroupId              = model.GroupId,
                TeamLeadId           = model.TeamLeadId,
                IsAssignedToAllUsers = model.IsAssignedToAllUsers
            };

            await messageBus.Publish(memberModel);

            if (model.IsUnassignAll)
            {
                await jobStatusService.Pending(dayAssign.Id, dayAssign.StatusId);
            }
            else if (dayAssign.StatusId != JobStatus.Opened && !model.TeamLeadId.HasValue)
            {
                await jobStatusService.Opened(dayAssign.Id, dayAssign.StatusId);
            }
            else if (dayAssign.StatusId != JobStatus.Assigned && model.TeamLeadId.HasValue)
            {
                await jobStatusService.Assigned(dayAssign.Id, dayAssign.StatusId);
            }
        }