public void AddComment(LotComment lotComment) { //Don`t check id`s, because //This will throw exception if UserId is wrong userAccountOperationsHandler.GetUserAccount(lotComment.UserId); //This will throw exception if LotId if wrong Lot lot = lotOperationsHandler.GetLot(lotComment.LotId); lot.LotComments = GetLotComments(lot.Id).ToList(); lot.AddComment(lotComment); UoW.LotComments.Add(mapper.Map <LotCommentEntity>(lotComment)); UoW.SaveChanges(); //private ChangeLot, without checking Lot again lotOperationsHandler.ChangeLotUnsafe(lot); }
public async Task AddCommentAsync(LotComment lotComment) { //Don`t check id`s, because //This will throw exception if UserId is wrong await userAccountOperationsHandler.GetUserAccountAsync(lotComment.UserId); //This will throw exception if LotId if wrong Lot lot = await lotOperationsHandler.GetLotAsync(lotComment.LotId); lot.LotComments = (await GetLotCommentsAsync(lot.Id)).ToList(); lot.AddComment(lotComment); UoW.LotComments.Add(mapper.Map <LotCommentEntity>(lotComment)); await UoW.SaveChangesAsync(); //private ChangeLot, without checking Lot again await lotOperationsHandler.ChangeLotUnsafeAsync(lot); }