Exemplo n.º 1
0
        public async Task <IHttpActionResult> PostClassVideoSale(ClassVideoSale classVideoSale)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ClassVideoSales.Add(classVideoSale);

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

            return(CreatedAtRoute("DefaultApi", new { id = classVideoSale.id }, classVideoSale));
        }
        public async Task <IActionResult> PutClassVideoSale(Guid id, ClassVideoSale classVideoSale)
        {
            if (id != classVideoSale.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> PutClassVideoSale(Guid id, ClassVideoSale classVideoSale)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,ClassVideoId,SaleId,Price")] ClassVideoSale classVideoSale)
        {
            if (id != classVideoSale.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(classVideoSale);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClassVideoSaleExists(classVideoSale.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassVideoId"] = new SelectList(_context.ClassVideo, "Id", "Id", classVideoSale.ClassVideoId);
            ViewData["SaleId"]       = new SelectList(_context.Sale, "Id", "BuyerId", classVideoSale.SaleId);
            return(View(classVideoSale));
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> GetClassVideoSale(Guid id)
        {
            ClassVideoSale classVideoSale = await db.ClassVideoSales.FindAsync(id);

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

            return(Ok(classVideoSale));
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> DeleteClassVideoSale(Guid id)
        {
            ClassVideoSale classVideoSale = await db.ClassVideoSales.FindAsync(id);

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

            db.ClassVideoSales.Remove(classVideoSale);
            await db.SaveChangesAsync();

            return(Ok(classVideoSale));
        }
        public async Task <IActionResult> Create([Bind("Id,ClassVideoId,SaleId,Price")] ClassVideoSale classVideoSale)
        {
            if (ModelState.IsValid)
            {
                classVideoSale.Id = Guid.NewGuid();
                _context.Add(classVideoSale);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassVideoId"] = new SelectList(_context.ClassVideo, "Id", "Id", classVideoSale.ClassVideoId);
            ViewData["SaleId"]       = new SelectList(_context.Sale, "Id", "BuyerId", classVideoSale.SaleId);
            return(View(classVideoSale));
        }
        public async Task <ActionResult <ClassVideoSale> > PostClassVideoSale(ClassVideoSale classVideoSale)
        {
            _context.ClassVideoSale.Add(classVideoSale);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ClassVideoSaleExists(classVideoSale.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetClassVideoSale", new { id = classVideoSale.Id }, classVideoSale));
        }