private Year ToYear(YearDto dto, int wealthId, string userId) { return(new Year { WealthId = wealthId, Name = dto.Name, Order = dto.Order }); }
public IActionResult AddYear(int wealthId, YearDto yearDto) { Year year = this.ToYear(yearDto, wealthId, User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier)?.Value); dbContext.Years.Add(year); this.dbContext.SaveChanges(); var location = this.Url.Action(nameof(this.GetYear), new { wealthId = wealthId, id = year.Id }); return(Created(location, ToYearDto(year))); }