コード例 #1
0
        public ActionResult DeletePersonnel(int?id)
        {
            if (id == null)
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
            SuppProjectPersonnels personnel = supportProjectPersonnelsManager.Find(x => x.Personnels.Id == id);

            if (personnel == null)
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
            var res = supportProjectPersonnelsManager.Delete(personnel);

            if (res > 0)
            {
                return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public ActionResult AddPersonnel(int?PersonnelID, string position, int projectID)
        {
            if (PersonnelID == null || position == null || projectID <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Personnels personnels = personnelManager.Find(x => x.Id == PersonnelID);

            if (personnels == null)
            {
                return(HttpNotFound());
            }
            SuppProjectPersonnels suppProjectPersonnels;

            suppProjectPersonnels = suppProjectPersonnelsManager.Find(x => x.Personnels.Id == PersonnelID && x.SuppProjects.ID == projectID);
            if (suppProjectPersonnels != null)
            {
                ViewBag.MESAJ = "Personnel already available";
                return(View(suppProjectPersonnels));
            }
            suppProjectPersonnels              = new SuppProjectPersonnels();
            suppProjectPersonnels.Personnels   = personnels;
            suppProjectPersonnels.Position     = position;
            suppProjectPersonnels.SuppProjectD = projectID;
            var res = supportProjectPersonnelsManager.Insert(suppProjectPersonnels);

            if (res > 0)
            {
                TempData["mesaj"] = "Added";
            }
            else
            {
                ViewBag.MESAJ = "Error. Please check fields.";
                return(View(suppProjectPersonnels));
            }
            return(RedirectToAction("Detail", new { id = projectID }));
        }