public async Task <IHttpActionResult> PostTutorialPromoPhoto(TutorialPromoPhoto tutorialPromoPhoto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TutorialPromoPhotoes.Add(tutorialPromoPhoto);

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

            return(CreatedAtRoute("DefaultApi", new { id = tutorialPromoPhoto.id }, tutorialPromoPhoto));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,TutorialId,PromoPhotoId")] TutorialPromoPhoto tutorialPromoPhoto)
        {
            if (id != tutorialPromoPhoto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tutorialPromoPhoto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TutorialPromoPhotoExists(tutorialPromoPhoto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PromoPhotoId"] = new SelectList(_context.PromoPhotos, "Id", "Id", tutorialPromoPhoto.PromoPhotoId);
            ViewData["TutorialId"]   = new SelectList(_context.Tutorial, "Id", "Id", tutorialPromoPhoto.TutorialId);
            return(View(tutorialPromoPhoto));
        }
        public async Task <IHttpActionResult> PutTutorialPromoPhoto(Guid id, TutorialPromoPhoto tutorialPromoPhoto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #4
0
        public async Task <IActionResult> PutTutorialPromoPhoto(Guid id, TutorialPromoPhoto tutorialPromoPhoto)
        {
            if (id != tutorialPromoPhoto.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IHttpActionResult> GetTutorialPromoPhoto(Guid id)
        {
            TutorialPromoPhoto tutorialPromoPhoto = await db.TutorialPromoPhotoes.FindAsync(id);

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

            return(Ok(tutorialPromoPhoto));
        }
        public async Task <IHttpActionResult> DeleteTutorialPromoPhoto(Guid id)
        {
            TutorialPromoPhoto tutorialPromoPhoto = await db.TutorialPromoPhotoes.FindAsync(id);

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

            db.TutorialPromoPhotoes.Remove(tutorialPromoPhoto);
            await db.SaveChangesAsync();

            return(Ok(tutorialPromoPhoto));
        }
        public async Task <IActionResult> Create([Bind("Id,TutorialId,PromoPhotoId")] TutorialPromoPhoto tutorialPromoPhoto)
        {
            if (ModelState.IsValid)
            {
                tutorialPromoPhoto.Id = Guid.NewGuid();
                _context.Add(tutorialPromoPhoto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PromoPhotoId"] = new SelectList(_context.PromoPhotos, "Id", "Id", tutorialPromoPhoto.PromoPhotoId);
            ViewData["TutorialId"]   = new SelectList(_context.Tutorial, "Id", "Id", tutorialPromoPhoto.TutorialId);
            return(View(tutorialPromoPhoto));
        }
Пример #8
0
        public async Task <ActionResult <TutorialPromoPhoto> > PostTutorialPromoPhoto(TutorialPromoPhoto tutorialPromoPhoto)
        {
            _context.TutorialPromoPhoto.Add(tutorialPromoPhoto);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TutorialPromoPhotoExists(tutorialPromoPhoto.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTutorialPromoPhoto", new { id = tutorialPromoPhoto.Id }, tutorialPromoPhoto));
        }