public async Task <IHttpActionResult> PostStickerCattegory(StickerCattegory stickerCattegory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StickerCattegories.Add(stickerCattegory); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (StickerCattegoryExists(stickerCattegory.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = stickerCattegory.id }, stickerCattegory)); }
public async Task <IActionResult> PutStickerCattegory(Guid id, StickerCattegory stickerCattegory) { if (id != stickerCattegory.Id) { return(BadRequest()); } _context.Entry(stickerCattegory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StickerCattegoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutStickerCattegory(Guid id, StickerCattegory stickerCattegory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stickerCattegory.id) { return(BadRequest()); } db.Entry(stickerCattegory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StickerCattegoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,StickeId,CategoryId")] StickerCattegory stickerCattegory) { if (id != stickerCattegory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stickerCattegory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StickerCattegoryExists(stickerCattegory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", stickerCattegory.CategoryId); ViewData["StickeId"] = new SelectList(_context.Stickers, "Id", "UserId", stickerCattegory.StickeId); return(View(stickerCattegory)); }
public async Task <IHttpActionResult> GetStickerCattegory(Guid id) { StickerCattegory stickerCattegory = await db.StickerCattegories.FindAsync(id); if (stickerCattegory == null) { return(NotFound()); } return(Ok(stickerCattegory)); }
public async Task <IHttpActionResult> DeleteStickerCattegory(Guid id) { StickerCattegory stickerCattegory = await db.StickerCattegories.FindAsync(id); if (stickerCattegory == null) { return(NotFound()); } db.StickerCattegories.Remove(stickerCattegory); await db.SaveChangesAsync(); return(Ok(stickerCattegory)); }
public async Task <IActionResult> Create([Bind("Id,StickeId,CategoryId")] StickerCattegory stickerCattegory) { if (ModelState.IsValid) { stickerCattegory.Id = Guid.NewGuid(); _context.Add(stickerCattegory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", stickerCattegory.CategoryId); ViewData["StickeId"] = new SelectList(_context.Stickers, "Id", "UserId", stickerCattegory.StickeId); return(View(stickerCattegory)); }
public async Task <ActionResult <StickerCattegory> > PostStickerCattegory(StickerCattegory stickerCattegory) { _context.StickerCattegory.Add(stickerCattegory); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (StickerCattegoryExists(stickerCattegory.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetStickerCattegory", new { id = stickerCattegory.Id }, stickerCattegory)); }