public async Task <IActionResult> Edit(Guid id, [Bind("Id,PostId,CategoryId")] PostCattegory postCattegory)
        {
            if (id != postCattegory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(postCattegory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostCattegoryExists(postCattegory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Categories, "Id", "Id", postCattegory.PostId);
            ViewData["PostId"] = new SelectList(_context.Post, "Id", "Id", postCattegory.PostId);
            return(View(postCattegory));
        }
        public async Task <IActionResult> PutPostCattegory(Guid id, PostCattegory postCattegory)
        {
            if (id != postCattegory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(postCattegory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostCattegoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IHttpActionResult> PostPostCattegory(PostCattegory postCattegory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PostCattegories.Add(postCattegory);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PostCattegoryExists(postCattegory.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = postCattegory.id }, postCattegory));
        }
        public async Task <IHttpActionResult> PutPostCattegory(Guid id, PostCattegory postCattegory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != postCattegory.id)
            {
                return(BadRequest());
            }

            db.Entry(postCattegory).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostCattegoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetPostCattegory(Guid id)
        {
            PostCattegory postCattegory = await db.PostCattegories.FindAsync(id);

            if (postCattegory == null)
            {
                return(NotFound());
            }

            return(Ok(postCattegory));
        }
        public async Task <IActionResult> Create([Bind("Id,PostId,CategoryId")] PostCattegory postCattegory)
        {
            if (ModelState.IsValid)
            {
                postCattegory.Id = Guid.NewGuid();
                _context.Add(postCattegory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Categories, "Id", "Id", postCattegory.PostId);
            ViewData["PostId"] = new SelectList(_context.Post, "Id", "Id", postCattegory.PostId);
            return(View(postCattegory));
        }
        public async Task <IHttpActionResult> DeletePostCattegory(Guid id)
        {
            PostCattegory postCattegory = await db.PostCattegories.FindAsync(id);

            if (postCattegory == null)
            {
                return(NotFound());
            }

            db.PostCattegories.Remove(postCattegory);
            await db.SaveChangesAsync();

            return(Ok(postCattegory));
        }
        public async Task <ActionResult <PostCattegory> > PostPostCattegory(PostCattegory postCattegory)
        {
            _context.PostCattegory.Add(postCattegory);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PostCattegoryExists(postCattegory.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPostCattegory", new { id = postCattegory.Id }, postCattegory));
        }