public async Task <List <UserMoneyDetaleResponse> > DeleteMonthAsync(UserMoneyDetaleRequest moneyId, string userId) { MoneyDetale removeThis = Context.MoneyDetale.FirstOrDefault(x => x.Id == moneyId.Id); Context.MoneyDetale.Remove(removeThis); Context.SaveChanges(); return(await GetMonthAsync(userId, moneyId.Date.Month, 1)); }
public async Task <UserMoneyDetaleResponse> PostMonth(UserMoneyDetaleRequest userMoneyDetaleRequest, string userId) { //Maybe it's needed to add another auto mapper in the mvcInstaller MoneyDetale money = Mapper.Map <MoneyDetale>(userMoneyDetaleRequest); money.UserId = userId; money.Id = Guid.NewGuid().ToString(); await Context.MoneyDetale.AddAsync(money); await Context.SaveChangesAsync(); UserMoneyDetaleResponse userMoneyDetaleResponse = Mapper.Map <UserMoneyDetaleResponse>(money); return(userMoneyDetaleResponse); }
public async Task <IActionResult> DeleteMonth([FromBody] UserMoneyDetaleRequest userMoneyDetaleRequest) { List <UserMoneyDetaleResponse> userMoneyDetaleResponse = await MoneyService.DeleteMonthAsync(userMoneyDetaleRequest, GeneralExtantions.GetUserId(HttpContext)); return(Ok(userMoneyDetaleResponse)); }
[HttpPost(ApiRoutes.MoneyDetaleRoute.Post)] //ApiRoutes.MoneyDetaleRoute.Post public async Task <IActionResult> PostMonth([FromBody] UserMoneyDetaleRequest userMoneyDetaleRequest) { UserMoneyDetaleResponse userMoneyDetaleResponse = await MoneyService.PostMonth(userMoneyDetaleRequest, GeneralExtantions.GetUserId(HttpContext)); return(Ok(userMoneyDetaleResponse)); }