public ActionResult SellCrops(SellCrop crop)
        {
            ViewBag.SellCrops = "active";
            crop.FarmerId     = (int)Session["FarmerId"];
            int t = db.SellCrops.Count(r => r.FarmerId == crop.FarmerId && r.CategoryId == crop.CategoryId && r.CropId == crop.CropId);

            if (t != 0)
            {
                SellCrop s = db.SellCrops.First(r => r.FarmerId == crop.FarmerId && r.CategoryId == crop.CategoryId && r.CropId == crop.CropId);
                s.Price     = crop.Price;
                s.Quantity += crop.Quantity;
                db.SaveChanges();
                ViewBag.Error = "Product List Updated Successfully";
            }
            else
            {
                db.SellCrops.Add(crop);
                db.SaveChanges();
                ViewBag.Error = "Product Listed for Sell Successfully";
            }

            ViewBag.Category = db.Categories.ToList();

            return(View());
        }
        public ActionResult Delete(int id)
        {
            SellCrop s = db.SellCrops.Find(id);

            db.SellCrops.Remove(s);
            db.SaveChanges();
            return(RedirectToAction("Profile"));
        }
        public ActionResult BoughtCrops(int amount, int id)
        {
            SellCrop sc = db.SellCrops.First(r => r.Id == id);

            sc.SoldCropAmount = amount;
            sc.Quantity       = sc.Quantity - amount;
            db.SaveChanges();
            int id2 = id;

            return(RedirectToAction("BuyCrops", "Admin", new{ id = id2, message = "Crop Bought Successfully" }));
        }