public async Task SetByStatusString(int orderId, string statusString, ClaimsPrincipal User) { var order = await _supplierOrderRepository.ReadAsync(o => o.Id == orderId); if (order == null) { throw new NotFoundException(); } var status = await _repo.ReadAsync(s => s.String == statusString); if (status == null) { await _repo.CreateAsync(new SupplierOrderStatus { String = statusString }); status = await _repo.ReadAsync(s => s.String == statusString); } order.Statuses.Add(new SupplierOrderSupplierOrderStatus { SupplierOrderId = order.Id, SupplierOrderStatus = status, DateTime = DateTime.Now, }); await _supplierOrderRepository.UpdateAsync(order); }
public async Task <SupplierOrderDTO> ReadAsync(ClaimsPrincipal User, int id) { var o = await _repo.ReadAsync(o => o.Id == id); return(_mapper.Map <SupplierOrderDTO>(o)); }