public async Task DeleteDesign(int id) { DesignDto designdto = await GetDesign(id); Design design = await _context.Design.FirstOrDefaultAsync(d => d.Id == designdto.Id); _context.Entry(design).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; await _context.SaveChangesAsync(); }
public DesignBl(DesignDto dto) { if (dto != null) { Id = dto.Id; Name = dto.Name; Comment = dto.Comment; Price = dto.Price; PriceVip = dto.PriceVip; } }
public async Task <Design> UpdateDesign(int id, DesignDto incomingData) { Design design = await _context.Design.FirstOrDefaultAsync(x => x.Id == id); design.Title = incomingData.Title; design.DesignCoords = incomingData.DesignCoords; _context.Entry(design).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _context.SaveChangesAsync(); return(design); }
public async Task <IActionResult> PutDesign(int id, DesignDto incomingData) { if (id != incomingData.Id) { return(BadRequest()); } var updatedDesign = await _design.UpdateDesign(id, incomingData); return(Ok(updatedDesign)); }
public ActionResult <DesignDto> Add([FromBody] DesignDto dto) { try { var item = _bl.Add(dto); return(CreatedAtRoute("GetDesignById", new { Id = item.Id }, item)); } catch (Exception ex) { return(Conflict($"{ex.Message}: {ex?.InnerException}")); } }
public DesignDto Add(DesignDto dto) { var item = new Design() { Name = dto.Name, Comment = dto.Comment, Price = dto.Price, PriceVip = dto.PriceVip, }; _dao.Create(item); return(_map(item)); }
public ActionResult <DesignDto> Update([FromBody] DesignDto dto) { try { return(_bl.Update(dto)); } catch (KeyNotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(Conflict(ex.Message)); } }
public async Task <Design> CreateDesign(DesignDto incomingData) { Design design = new Design { Id = incomingData.Id, Title = incomingData.Title, DesignCoords = incomingData.DesignCoords, TimeStamp = DateTime.Now }; _context.Entry(design).State = Microsoft.EntityFrameworkCore.EntityState.Added; await _context.SaveChangesAsync(); return(design); }
public DesignDto Update(DesignDto dto) { var item = _dao.Get(dto.Id); if (item == null) { throw new KeyNotFoundException(); } item.Name = dto.Name; item.Comment = dto.Comment; item.Price = dto.Price; item.PriceVip = dto.PriceVip; _dao.Update(item); return(_map(item)); }
public DesignDto Update(DesignDto item) { return(Url.AppendPathSegment("Design") .PutJsonAsync(item).ReceiveJson <DesignDto>().Result); }
public async Task <ActionResult <Design> > PostDesign(DesignDto incomingData) { await _design.CreateDesign(incomingData); return(CreatedAtAction("GetDesign", new { id = incomingData.Id }, incomingData)); }