예제 #1
0
        public async Task AddPromoRewardRequest(PromoRewardRequestModel request)
        {
            var eventEntity = await _eventRepository.GetPureEvent(request.EventUid);

            var entity = new PromoRewardRequestEntity();

            entity.AccountingNumber       = request.AccountingNumber;
            entity.PromoRewardRequestUid  = Guid.NewGuid();
            entity.PromoRewardRequestTime = DateTime.UtcNow;
            entity.EventId = eventEntity.EventId;
            if (request.Images != null)
            {
                var images = new List <PromoRewardRequestImageContentEntity>();
                foreach (var image in request.Images)
                {
                    var imageUid = await _imageLogic.SaveImage(image);

                    images.Add(new PromoRewardRequestImageContentEntity {
                        PromoRewardRequestImageContentUid = imageUid
                    });
                }
                entity.Images = images;
            }
            await _eventRepository.AddPromoRewardRequest(entity);
        }
예제 #2
0
        public async Task <ActionResult> AddPromoRewardRequest(PromoRewardRequestModel request)
        {
            var validationResult = _eventValidation.ValidateAddPromoRewardRequest(request);

            if (!validationResult.ValidationResult)
            {
                return(BadRequest(validationResult.ValidationMessage));
            }
            await _eventLogic.AddPromoRewardRequest(request);

            return(Ok(Messages.GetMessageJson(MessageTitles.PromoRewardRequestAdded, CultureParser.GetCultureFromHttpContext(HttpContext))));
        }
예제 #3
0
        public (bool ValidationResult, string ValidationMessage) ValidateAddPromoRewardRequest(PromoRewardRequestModel request)
        {
            if (request.Images == null || request.Images.Count < 1 || request.Images.Count > 2)
            {
                return(false, ErrorDictionary.GetErrorMessage(47, _culture));
            }
            if (string.IsNullOrWhiteSpace(request.AccountingNumber))
            {
                return(false, ErrorDictionary.GetErrorMessage(48, _culture));
            }
            var eventEntity = _eventRepository.GetEvent(request.EventUid).Result;

            if (eventEntity == null)
            {
                return(false, ErrorDictionary.GetErrorMessage(10, _culture));
            }
            if (eventEntity.EventStatusId != (long)EventStatus.Ended)
            {
                return(false, ErrorDictionary.GetErrorMessage(49, _culture));
            }
            if (eventEntity.PromoRewardRequests.Any())
            {
                return(false, ErrorDictionary.GetErrorMessage(54, _culture));
            }
            return(true, string.Empty);
        }