In my application Api retun http 404 when i try do add element to list why? When i comment line in constuctor with adding element to list api return json with Order and work good.In my application Api retun http 404 when i try do add element to list why? When i comment line in constuctor with adding element to list api return json with Order and work good.
public class Order
{
public List<pizza> Pizza { get; set; }
public Order(int orderId, User user, string adress, string fullname, string zip_code, string city, string phonenumber, pizza pizza)
{
Pizza.Add(pizza);
OrderId = orderId;
OrderCreate = DateTime.UtcNow;
user = this.user;
SetZipCode(zip_code);
AddressLine = adress;
FullName = fullname;
City = city;
SetPhoneNumber(phonenumber);
}
}
public class OrderService : IOrderService
{
public readonly IMapper _mapper;
public readonly IOrderRepository _orderRepository;
public OrderService(IOrderRepository customerRepository, IMapper mapper)
{
_mapper = mapper;
_orderRepository = customerRepository;
}
public Task CreateAsync(int orderId)
{
throw new NotImplementedException();
}
public async Task CreateAsync(int orderId, User user, string adress, string fullname, string zip_code, string city, string phonenumber, pizza pizza)
{
var order = await _orderRepository.GetAsync(orderId);
if (order != null)
{
throw new Exception($"User with {order} already exist");
}
order = new Order(orderId, user, adress,fullname,zip_code,city,phonenumber,pizza);
await _orderRepository.AddAsync(order);
}
public Task DeleteAsync(int orderId)
{
throw new NotImplementedException();
}
public async Task<Order> GetAsync(int OrderId)
{
var order = await _orderRepository.GetAsync(OrderId);
return order;
}
}
enter code here
Aucun commentaire:
Enregistrer un commentaire