public async Task <IHttpActionResult> PutDingPromo(int id, DingPromo dingPromo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            DingPromo dingPromo = await db.DingPromo.FindAsync(id);

            db.DingPromo.Remove(dingPromo);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IHttpActionResult> GetDingPromo(int id)
        {
            DingPromo dingPromo = await db.DingPromo.FindAsync(id);

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

            return(Ok(dingPromo));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,ProviderCode,StartUtc,EndUtc,Promo,Min,Max,MontoText,Estado")] DingPromo dingPromo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dingPromo).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(dingPromo));
        }
        public async Task <IHttpActionResult> PostDingPromo(DingPromo dingPromo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DingPromo.Add(dingPromo);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = dingPromo.Id }, dingPromo));
        }
        public async Task <IHttpActionResult> DeleteDingPromo(int id)
        {
            DingPromo dingPromo = await db.DingPromo.FindAsync(id);

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

            db.DingPromo.Remove(dingPromo);
            await db.SaveChangesAsync();

            return(Ok(dingPromo));
        }
        // GET: Admin/DingPromo/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DingPromo dingPromo = await db.DingPromo.FindAsync(id);

            if (dingPromo == null)
            {
                return(HttpNotFound());
            }
            return(View(dingPromo));
        }