public async Task <ErrorRepsonse <ClientDto> > GivePoints(GiveOrDiscountPointsDto giveOrDiscountPointsDto) { var client = await _uintOfWork.Repository <Client>().GetById(giveOrDiscountPointsDto.ClientId); await _uintOfWork.BegeinTransaction(); try { string sen = ""; if (giveOrDiscountPointsDto.IsGive) { client.Points += giveOrDiscountPointsDto.Points; sen += $"تم إهدائك {giveOrDiscountPointsDto.Points} نقاط"; } else { client.Points -= giveOrDiscountPointsDto.Points; sen += $"تم خصم {giveOrDiscountPointsDto.Points} نقاط منك"; } Notfication notfication = new Notfication() { ClientId = client.Id, Note = sen, }; await _uintOfWork.Repository <Client>().Update(client); await _uintOfWork.Repository <Notfication>().AddAsync(notfication); await _uintOfWork.Commit(); RemoveCash(); return(new ErrorRepsonse <ClientDto>() { Data = _mapper.Map <ClientDto>(client) }); } catch (Exception ex) { await _uintOfWork.RoleBack(); throw ex; } }
public async Task <IActionResult> GivePoint([FromBody] GiveOrDiscountPointsDto giveOrDiscountPointsDto) { await _clientCashedService.GivePoints(giveOrDiscountPointsDto); return(Ok()); }