示例#1
0
        public DTO.Restriction Get(bool isRKAdmin, Guid clientId, Guid roleCode, Guid code)
        {
            var result = restrictionRepository.Get(code);

            if (!isRKAdmin)
            {
                var appStore = applicationStoreRepository.GetByClientId(clientId);

                if (result != null && appStore.StoreCode != result.Role.Store.Code)
                {
                    throw new ArgumentException("Usuário não possui permissão para realizar essa operação");
                }
            }

            if (result.IsNull())
            {
                throw new ArgumentException("Restrição não encontrada");
            }

            if (result.RoleCode != roleCode)
            {
                throw new ArgumentException("Restrição não pertence ao grupo informado");
            }

            return(result.GetResult());
        }
示例#2
0
        private void ValidateInput(CreateRestriction command)
        {
            if (!string.IsNullOrWhiteSpace(command.ExternalIdentifier))
            {
                var restriction = _restrictionRepository.Get(command.ExternalIdentifier);
                if (restriction != null)
                {
                    var msg = $"Restriction with external identifier: '{command.ExternalIdentifier}' already exists";
                    throw new InvalidDataException(msg);
                }
            }

            ValidateRestrictionDatesAndDays(command.StartDate, command.EndDate, command.RestrictionDays);

            if (command.SalesAreas != null && command.SalesAreas.Any())
            {
                _salesAreaRepository.ValidateSaleArea(command.SalesAreas);
            }

            CustomValidation(command);

            if (!string.IsNullOrWhiteSpace(command.ProgrammeCategory) && !_programmeCategoryRepository.IsValid(
                    new List <string> {
                command.ProgrammeCategory
            },
                    out List <string> invalidList))
            {
                var msg = string.Concat("Invalid programme category: ",
                                        invalidList != null ? invalidList.FirstOrDefault() : string.Empty);
                throw new InvalidDataException(msg);
            }

            if (!string.IsNullOrWhiteSpace(command.ClearanceCode))
            {
                _clearanceRepository.ValidateClearanceCode(new List <string> {
                    command.ClearanceCode
                });
            }
        }
示例#3
0
 public Restriction Get(int id)
 {
     return(_repo.Get(id));
 }
示例#4
0
 public ReleaseProfile Get(int id)
 {
     return(_repo.Get(id));
 }
示例#5
0
 public Restriction Get(Int32 id)
 {
     return(_repo.Get(id));
 }