Beispiel #1
0
        public JsonResult EditOrganization(int id, string name, string manger_id)
        {
            showmangerviewmodel orgg = new showmangerviewmodel();
            var orgs = db.organization.Where(c => c.name == name).ToList();
            var org  = db.organization.SingleOrDefault(c => c.id == id);

            orgs.Remove(org);
            int result = 0;

            if (orgs.Count() != 0)
            {
                result = 0;
            }
            else
            {
                org.name    = name;
                orgg.manger = db.user.ToList();
                List <user> allmanger = new List <user>();
                foreach (var x in orgg.manger)
                {
                    if (x.person_id == 2 && manger_id == x.name)
                    {
                        orgg.name     = name;
                        org.name      = name;
                        org.manger_id = x.id;
                        allmanger.Add(x);
                        db.SaveChanges();
                        result = 1;
                    }
                }
            }
            return(Json(new { result, JsonRequestBehavior.AllowGet }));
        }
Beispiel #2
0
        public ActionResult EditOrganization(int id)
        {
            string n;
            var    org = db.organization.Find(id);
            showmangerviewmodel obj = new showmangerviewmodel();
            var all = org.name;

            obj.id        = org.id;
            obj.name      = org.name;
            obj.manger_id = org.user.name;
            obj.manger    = db.user.ToList();

            List <user> allmanger = new List <user>();

            foreach (var x in obj.manger)
            {
                if (x.person_id == 2 && x.id == org.manger_id)
                {
                    allmanger.Add(x);
                    ViewBag.n = x.name;
                }
            }
            return(View(obj));
        }