示例#1
0
        public async Task UpdateAsync(Guid id, OrderUpdate model)
        {
            Has.NotNull(model);

            if (!id.Equals(model.Id))
            {
                throw new InvalidOperationException($"This IDs don't match: {id} and {model.Id}");
            }

            var entity = await _unitOfWork.Orders.GetByIdAsync(model.Id);

            await _unitOfWork.SetAllReferences(DeletedOrderReference.GetInstance(entity, model));


            //Adding new links received from the UI
            await _unitOfWork.SetAllReferences(InsertOrderReferences.GetInstance(entity, model));

            await _unitOfWork.Orders.UpdateAsync(id, _mapper.Map(model, entity));
        }
 public static async Task SetAllReferences(this IUnitOfWork unitOfWork, DeletedOrderReference model)
 => await ReferenceHelper.SetAllReferences(unitOfWork, model, (@ref, id) => @ref.Orders.Remove(id));