public IHttpActionResult Create(OrderCreatingModel orderModel)
        {
            var     client = ClientHelper.GetClient(context, orderModel.Identifier, orderModel.IdentifierType);
            HereApi api    = new HereApi();
            Order   order  = new Order()
            {
                Id = Guid.NewGuid(),
                CreationTimestamp    = DateTime.Now,
                State                = OrderStateEnum.Draft,
                Description          = orderModel.Description,
                Photo                = orderModel.Photo,
                RecipientDescription = orderModel.RecipientDescription,
                EndAddress           = api.GetAdress(orderModel.EndAddressCoords),
                EndAddressCoords     = orderModel.EndAddressCoords,
                StartAddress         = api.GetAdress(orderModel.StartAddressCoords),
                StartAddressCoords   = orderModel.StartAddressCoords,
                ClientId             = client.Id,
                StateChangeTimestamp = DateTime.Now
            };

            context.GetTable <Order>().InsertOnSubmit(order);

            context.SubmitChanges();

            return(Ok());
        }
Beispiel #2
0
        public async Task <int> CreateOrder(OrderCreatingModel model)
        {
            var orderEntity = (OrderEntity)model;

            orderEntity.PostamatId = _context.Postamats.First(entity => entity.Number == model.PostamatNumber).Id;
            await _context.Orders.AddAsync(orderEntity);

            await _context.SaveChangesAsync();

            return(orderEntity.Id);
        }
Beispiel #3
0
 public Task <int> Create(OrderCreatingModel model) => _service.CreateOrder(model);