コード例 #1
0
 private static Persistence.EntityFramework.Entities.Shipper Map(Models.Shippers.Shipper modelShipper)
 {
     return(new Persistence.EntityFramework.Entities.Shipper()
     {
         ShipperId = modelShipper.ShipperId,
         CompanyName = modelShipper.CompanyName
     });
 }
コード例 #2
0
        public async Task Delete(Models.Shippers.Shipper model, CancellationToken cancellationToken = default)
        {
            var shipperDb = await DbContext.Shippers
                            .Where(x => x.ShipperId == model.ShipperId)
                            .FirstOrDefaultAsync(cancellationToken);

            DbContext.Shippers.Remove(shipperDb);

            await DbContext.SaveChangesAsync(cancellationToken);
        }
コード例 #3
0
        public async Task <Models.Shippers.Shipper> Edit(Models.Shippers.Shipper model, CancellationToken cancellationToken = default)
        {
            var shipperDb = await DbContext.Shippers
                            .FirstOrDefaultAsync(x => x.ShipperId == model.ShipperId, cancellationToken);

            shipperDb = DbContext.Shippers.Update(Map(shipperDb, model)).Entity;

            await DbContext.SaveChangesAsync(cancellationToken);

            return(Map(shipperDb));
        }
コード例 #4
0
        public async Task <OrderDetails> CreateFromCart(CostumerCart cart, Models.Shippers.Shipper shipper, CancellationToken cancellationToken = default)
        {
            if (cart.Costumer == null || cart.Costumer.CustomerId == default)
            {
                throw new CustomerRegistrationException();
            }

            return(await Create(new OrderDetails()
            {
                Customer = cart.Costumer,
                OrderDate = DateTime.Now,
                Shipper = shipper,
                Products = cart.CartProducts
            }, cancellationToken));
        }
コード例 #5
0
        private static Persistence.EntityFramework.Entities.Shipper Map(Persistence.EntityFramework.Entities.Shipper shipperDb, Models.Shippers.Shipper modelShipper)
        {
            shipperDb.CompanyName = modelShipper.CompanyName;

            return(shipperDb);
        }
コード例 #6
0
        public async Task <Models.Shippers.Shipper> Create(Models.Shippers.Shipper model, CancellationToken cancellationToken = default)
        {
            var shipper = await DbContext.Shippers.AddAsync(Map(model), cancellationToken);

            return(Map(shipper.Entity));
        }