Example #1
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            WasteCategory wasteCategory = await db.WasteCategory.FindAsync(id);

            db.WasteCategory.Remove(wasteCategory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #2
0
        public async Task <ActionResult> Edit([Bind(Include = "wCategoryId,wName,pricePerKg")] WasteCategory wasteCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(wasteCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(wasteCategory));
        }
Example #3
0
        // GET: WasteCategories/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WasteCategory wasteCategory = await db.WasteCategory.FindAsync(id);

            if (wasteCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(wasteCategory));
        }
Example #4
0
        public async Task <ActionResult> Create([Bind(Include = "wCategoryId,wName,pricePerKg")] WasteCategory wasteCategory)
        {
            if (ModelState.IsValid)
            {
                if (wasteCategory.pricePerKg < 0)
                {
                    ModelState.AddModelError("", "You Can Not Enter A Value Less Than Zero/ Negetive");
                }
                else
                {
                    db.WasteCategory.Add(wasteCategory);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(wasteCategory));
        }