public Catalog UpdateElement(CatalogNewDto newItem, Catalog entity) { entity.Id = newItem.Id; entity.Name = newItem.Name; entity.FatherId = newItem.FatherId; return(entity); }
public async Task <dynamic> CreateAsync(CatalogNewDto newItem) { var entity = _mapper.NewElement(newItem); await _context.AddAsync(entity); await _context.SaveChangesAsync(); return(new { Id = entity.Id }); }
public async Task <dynamic> UpdateByIdAsync(string id, CatalogNewDto newItem) { var entity = await _context.Catalogs.FindAsync(id); if (entity == null) { return(null); } _context.Update(_mapper.UpdateElement(newItem, entity)); await _context.SaveChangesAsync(); return(new { Id = id }); }
public async Task <ActionResult <CatalogDetailsDto> > CreateAsync([FromBody] CatalogNewDto newItem, string authentication) { bool check = await _authentication.IsLoginAsync(authentication); if (check) { var result = await _service.CreateAsync(newItem); if (result == null) { return(NotFound()); } return(CreatedAtAction(nameof(GetByIdAsync), new { id = result.Id }, result));; } return(BadRequest("Not Loggin")); }
public Catalog NewElement(CatalogNewDto dto) => new Catalog() { Id = dto.Id, Name = dto.Name, FatherId = dto.FatherId };