コード例 #1
0
        public async Task <ActionResult <Postamat> > GetPostamatByIdAsync(string num)
        {
            var postamat = await _postamatRepository.GetByIdAsync(num);

            if (postamat == null)
            {
                return(NotFound());
            }

            return(postamat);
        }
コード例 #2
0
        public async Task <IActionResult> CreateOrderAsync(CreateOrderResponse response)
        {
            Match match = Regex.Match(response.PhoneNumber, @"^\+7\d{3}-\d{3}-\d{2}-\d{2}$");

            if (!match.Success)
            {
                return(BadRequest());
            }

            if (response.Blocks.Count() > 10)
            {
                return(BadRequest());
            }

            var postamat = await _postamatRepository.GetByIdAsync(response.PostamatNumber.ToString());

            if (postamat == null)
            {
                return(NotFound());
            }
            if (postamat.Status == false)
            {
                return(Forbid());
            }

            Order order = new Order
            {
                Number         = response.Number,
                Blocks         = response.Blocks,
                Cost           = response.Cost,
                PhoneNumber    = response.PhoneNumber,
                PostamatNumber = response.PostamatNumber,
                Recipient      = response.Recipient,
                StatusOrder    = Core.Types.StatusOrder.Registered,
            };

            await _orderRepository.CreateAsync(order);

            return(Ok());
        }