Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            string CurrentLoginID = User.Identity.GetUserId().ToString();

            var userIDselectVar = from s in db.agentsDbs where s.userID == CurrentLoginID select s.ID;
            int userIDselectInt = userIDselectVar.Single();

            List <int> returnProjectIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                             .Select(s => s.projectID)
                                             .ToList();

            List <int> returnTaskOrdersIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                                .Select(s => s.taskOrderID)
                                                .ToList();

            var userTypeSelect = from s in db.agentsDbs where s.userID == CurrentLoginID select s.userType;
            int userTypeInt    = userTypeSelect.First();

            if (userTypeInt == 2 || (CurrentLoginID == User.Identity.GetUserId().ToString() && returnProjectIDlist.Contains(10) &&
                                     returnTaskOrdersIDlist.Contains(41)))
            {
                k2017orgStrL3Db k2017orgStrL3Db = db.k2017orgStrL3Dbs.Find(id);
                db.k2017orgStrL3Dbs.Remove(k2017orgStrL3Db);
                db.SaveChanges();
                return(RedirectToAction("Index", "k2017orgAdmStructure", new { projectID = 10, taskOrderID = 41, Int1 = 1 }));
            }
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "ID, projectID, taskOrderID, orgStrL1ID, orgStrL2ID, orgStrL3, createdDT, editedDT, createdByUserID")] k2017orgStrL3Db k2017orgStrL3Db)
        {
            string CurrentLoginID = User.Identity.GetUserId().ToString();

            var userIDselectVar = from s in db.agentsDbs where s.userID == CurrentLoginID select s.ID;
            int userIDselectInt = userIDselectVar.Single();

            List <int> returnProjectIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                             .Select(s => s.projectID)
                                             .ToList();

            List <int> returnTaskOrdersIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                                .Select(s => s.taskOrderID)
                                                .ToList();

            var userTypeSelect = from s in db.agentsDbs where s.userID == CurrentLoginID select s.userType;
            int userTypeInt    = userTypeSelect.First();

            if (userTypeInt == 2 || (CurrentLoginID == User.Identity.GetUserId().ToString() && returnProjectIDlist.Contains(10) &&
                                     returnTaskOrdersIDlist.Contains(41)))
            {
                if (ModelState.IsValid)
                {
                    db.Entry(k2017orgStrL3Db).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", "k2017orgAdmStructure", new { projectID = 10, taskOrderID = 41, Int1 = 1 }));
                }
                return(View(k2017orgStrL3Db));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 3
0
        // GET: k2017orgStrL3Dbs/Delete/5
        public ActionResult Delete(int?id)
        {
            string CurrentLoginID = User.Identity.GetUserId().ToString();

            var userIDselectVar = from s in db.agentsDbs where s.userID == CurrentLoginID select s.ID;
            int userIDselectInt = userIDselectVar.Single();

            List <int> returnProjectIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                             .Select(s => s.projectID)
                                             .ToList();

            List <int> returnTaskOrdersIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                                .Select(s => s.taskOrderID)
                                                .ToList();

            var userTypeSelect = from s in db.agentsDbs where s.userID == CurrentLoginID select s.userType;
            int userTypeInt    = userTypeSelect.First();

            if (userTypeInt == 2 || (CurrentLoginID == User.Identity.GetUserId().ToString() && returnProjectIDlist.Contains(10) &&
                                     returnTaskOrdersIDlist.Contains(41)))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                k2017orgStrL3Db k2017orgStrL3Db = db.k2017orgStrL3Dbs.Find(id);
                if (k2017orgStrL3Db == null)
                {
                    return(HttpNotFound());
                }
                return(View(k2017orgStrL3Db));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 4
0
        // GET: k2017orgStrL3Dbs/Edit/5
        public ActionResult Edit(int?id)
        {
            System.Diagnostics.Debug.WriteLine(id);

            string CurrentLoginID = User.Identity.GetUserId().ToString();

            var userIDselectVar = from s in db.agentsDbs where s.userID == CurrentLoginID select s.ID;
            int userIDselectInt = userIDselectVar.Single();

            List <int> returnProjectIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                             .Select(s => s.projectID)
                                             .ToList();

            List <int> returnTaskOrdersIDlist = db.agentsTaskOrdersDbs.Where(s => s.agentID == userIDselectInt)
                                                .Select(s => s.taskOrderID)
                                                .ToList();

            var userTypeSelect = from s in db.agentsDbs where s.userID == CurrentLoginID select s.userType;
            int userTypeInt    = userTypeSelect.First();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            k2017orgStrL3Db k2017orgStrL3Db = db.k2017orgStrL3Dbs.Find(id);

            if (k2017orgStrL3Db == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (userTypeInt == 2 || (CurrentLoginID == User.Identity.GetUserId().ToString() && returnProjectIDlist.Contains(10) &&
                                     returnTaskOrdersIDlist.Contains(41)))
            {
                ViewBag.currUL310 = User.Identity.GetUserId().ToString();
                ViewBag.currDT310 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                ViewBag.proj300 = new SelectList(db.clientsProjectsDbs.Where(s => s.ID == 1 || s.ID == 10)
                                                 .OrderBy(s => s.ID), "ID", "projectName");

                ViewBag.task300 = new SelectList(db.taskOrdersDbs.Where(s => s.ID == 1 || s.ID == 41)
                                                 .OrderBy(s => s.ID), "ID", "taskOrder");

                ViewBag.stL1300 = new SelectList(db.k2017orgStrL1Dbs.OrderBy(s => s.ID), "ID", "orgStrL1");


                var It02 = db.k2017orgStrL3Dbs.Where(s => s.ID == id)
                           .Select(s => s.orgStrL1ID)
                           .First();

                ViewBag.stL2300 = new SelectList(db.k2017orgStrL2Dbs.Where(s => s.ID == 1 || s.orgStrL1ID == It02)
                                                 .OrderBy(s => s.ID), "ID", "orgStrL2");

                var    Item32  = from m in db.k2017orgStrL3Dbs where m.ID == id select m.createdByUserID;
                string Item322 = Item32.Single();

                var    Item2110  = from m in db.agentsDbs where m.userID == Item322 select m.agentName;
                string ItemID200 = Item2110.Single();
                ViewBag.agnm301 = ItemID200;


                return(View(k2017orgStrL3Db));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }