コード例 #1
0
        public async Task <GeneralResponseDto> ReceiveRequest(ReceivePromotionInputDto InputDto)
        {
            GeneralResponseDto added = new GeneralResponseDto {
                status = 2, Message = "Failed"
            };
            bool isExist = await _unitOfWork.Promotion.GetAnyAsync(p => p.MobileNumber == InputDto.MobileNumber);

            if (!isExist)
            {
                //create random id
                Random rnd = new Random();
                int    id  = rnd.Next(1, rnd.Next(2, 500)) * 10;

                Promotion promotion = new Promotion
                {
                    RequestId    = id,
                    MobileNumber = InputDto.MobileNumber,
                    Action       = InputDto.Action,
                    IsHandled    = false,
                    RequestDate  = DateTime.Now
                };
                _unitOfWork.Promotion.CreateAsyn(promotion);

                if (await _unitOfWork.Commit() > default(int))
                {
                    added.status  = 1;
                    added.Message = "Success";
                }
            }
            return(added);
        }
コード例 #2
0
        public async Task <IHttpActionResult> ReceiveRequest(ReceivePromotionInputDto inputDto)
        {
            GeneralResponseDto result = await _promotionService.ReceiveRequest(inputDto);

            return(Ok(result));
        }