Пример #1
0
        public CreateOutput <TeamDto, long> Create(CreateTeamInput input)
        {
            Team newTeamEntity = input.Entity.MapTo <Team>();

            if (!TeamPolicy.CanCreateEntity(newTeamEntity))
            {
                throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionCreateDenied, "\"Team\"");
            }

            newTeamEntity.IsActive  = true;
            newTeamEntity.IsDefault = false;

            TeamRepository.Includes.Add(r => r.LastModifierUser);
            TeamRepository.Includes.Add(r => r.CreatorUser);
            TeamRepository.Includes.Add(r => r.PlayerCareers);

            TeamDto newTeamDto = (TeamRepository.Insert(newTeamEntity)).MapTo <TeamDto>();

            TeamRepository.Includes.Clear();

            return(new CreateOutput <TeamDto, long>()
            {
                CreatedEntity = newTeamDto
            });
        }
Пример #2
0
 public async Task CreateOrUpdateTeam(CreateTeamInput input)
 {
     if (input.Id != 0)
     {
         await UpdateTeam(input);
     }
     else
     {
         await CreateTeam(input);
     }
 }
Пример #3
0
        public async Task CreateTeam(CreateTeamInput input)
        {
            var team = input.MapTo <Teams>();
            var val  = _TeamsRepository
                       .GetAll().Where(p => p.Name == input.Name && p.SalesManagerId == input.SalesManagerId).FirstOrDefault();

            if (val == null)
            {
                await _TeamsRepository.InsertAsync(team);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Team '" + input.Name + "'...");
            }
        }