public ActionResult DeleteConfirmed(int id)
        {
            var       companyId = Convert.ToInt32(Session["CompanyID"]);
            acc_group vendor    = db.acc_group.Where(x => x.Company_Id == companyId && x.id == id && x.is_base_group == false).FirstOrDefault();

            db.acc_group.Remove(vendor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: accGroup/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var       companyId = 1;
            acc_group vendor    = db.acc_group.Where(x => x.Company_Id == companyId && x.id == id && x.is_base_group == false).FirstOrDefault();

            if (vendor == null)
            {
                return(HttpNotFound());
            }
            return(View(vendor));
        }
        public ActionResult Edit([Bind(Include = "Id,name,description,base_group")] acc_group vendor)
        {
            var companyId = Convert.ToInt32(Session["CompanyID"]);

            if (ModelState.IsValid)
            {
                db.Entry(vendor).State = EntityState.Modified;
                vendor.Company_Id      = companyId;
                vendor.is_base_group   = false;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.base_group = new SelectList(db.acc_group.Where(x => x.is_base_group == true && x.Company_Id == null), "id", "name");
            return(View(vendor));
        }
        // GET: accGroup/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var       companyId = Convert.ToInt32(Session["CompanyID"]);
            acc_group vendor    = db.acc_group.Where(x => x.Company_Id == companyId && x.id == id && x.is_base_group == false).FirstOrDefault();

            if (vendor == null)
            {
                return(HttpNotFound());
            }
            ViewBag.base_group = new SelectList(db.acc_group.Where(x => x.is_base_group == true && x.Company_Id == null), "id", "name", vendor.base_group_id);
            return(View(vendor));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "Id,name,description,base_group")] acc_group vendor)
        {
            var CompanyId = Convert.ToInt32(Session["CompanyID"]);

            if (ModelState.IsValid)
            {
                db.acc_group.Add(vendor);
                vendor.company_id    = CompanyId;
                vendor.is_base_group = false;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.base_group = new SelectList(db.acc_group.Where(x => x.is_base_group == true), "id", "name");
            return(View(vendor));
        }
        // GET: accGroup/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var       companyId = Convert.ToInt32(Session["CompanyID"]);
            acc_group vendor    = db.acc_group.Where(x => x.Company_Id == companyId && x.id == id && x.is_base_group == false).FirstOrDefault();

            if (vendor == null)
            {
                return(HttpNotFound());
            }
            db.acc_group.Remove(vendor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }