コード例 #1
0
        public ActionResult CreateProject(proj_infoViewModel info)
        {
            string projDesc = info._proj_name;

            if (ModelState.IsValid)
            {
                var p = new proj_info
                {
                    proj_name        = info._proj_name,
                    proj_mgr_id      = info._proj_mgr_id,
                    proj_sponsor_id  = info._proj_sponsor_id,
                    charter          = info._charter,
                    scope_definition = info._scope_definition,
                    dept_id          = info._dept_id,
                    client           = info._client,
                    proj_start_date  = info._proj_start_date.Value,
                    proj_end_date    = info._proj_end_date,
                    proj_status_id   = info._proj_status_id,
                    project_type_id  = info.proj_type_id,
                    createdby        = info._createdby,
                    createddate      = info._createddate.Value,
                    notes            = info._notes,
                    proj_goal        = info._proj_goal,
                    doc_location     = info._doc_location
                };
                _ctx.proj_info.Add(p);
                _ctx.SaveChanges();
                return(RedirectToAction("Index", new { searchTerm = projDesc }));
            }

            return(View(info));
        }
コード例 #2
0
//        [HttpPost]
        public ActionResult UpdateProject(proj_infoViewModel info, int id)
        {
            // this is how you access the list of errors that can occur during the model binding.
            if (!ModelState.IsValid)
            {
                return(View(info));
            }

            var p = projectInfo.GetProjectInfo(id);

            if (p == null)
            {
                return(RedirectToAction("Index"));
            }

            string projDesc = info._proj_name;
            var    pi       = new proj_info
            {
                proj_info_id     = id,
                proj_name        = info._proj_name,
                proj_mgr_id      = info._proj_mgr_id,
                proj_sponsor_id  = info._proj_sponsor_id,
                charter          = info._charter,
                scope_definition = info._scope_definition,
                dept_id          = info._dept_id,
                client           = info._client,
                proj_start_date  = info._proj_start_date.Value,
                proj_end_date    = info._proj_end_date,
                proj_status_id   = info._proj_status_id,
                project_type_id  = info.proj_type_id,
                createdby        = User.Identity.Name.Replace("GREENSPOONMARDE\\", ""),
                createddate      = DateTime.Now,
                notes            = info._notes,
                proj_goal        = info._proj_goal,
                doc_location     = info._doc_location
            };

            var existingProjInfo = _ctx.proj_info.Find(pi.proj_info_id);

            if (existingProjInfo != null)
            {
                // entity already in the context
                var attachedEntry = _ctx.Entry(existingProjInfo);
                attachedEntry.CurrentValues.SetValues(pi);
            }
            _ctx.SaveChanges();
            TempData["ConfirmationMessage"] = pi.proj_name + " has been updated.";
            // I want to redirect here instead of just letting the users sit on the save values on that posted form fields, it is very common after HTTP POST you redirect them back to a page where they
            // can view the changed results, THAT WAY, they don't hit refresh on the result of this post operation and accidentally submit something twice.
            return(RedirectToAction("Index", new { searchTerm = projDesc }));
        }
コード例 #3
0
        // GET Request
        public ActionResult CreateProject()
        {
            proj_infoViewModel projInfo = new proj_infoViewModel
            {
                _proj_name        = string.Empty,
                _proj_mgr_id      = 1,
                _proj_sponsor_id  = 1,
                _charter          = false,
                _scope_definition = string.Empty,
                _dept_id          = 1,
                _client           = string.Empty,
                _proj_start_date  = DateTime.Now,
                _proj_end_date    = null,
                _proj_status_id   = 1,
                proj_type_id      = 1,
                _createdby        = User.Identity.Name.Replace("GREENSPOONMARDE\\", ""),
                _createddate      = DateTime.Now,
                _notes            = string.Empty,
                _proj_goal        = string.Empty,
                _doc_location     = string.Empty
            };

            return(PartialView("CreateProject", projInfo));
        }
コード例 #4
0
        //        [HttpPost]
        public ActionResult UpdateProject(proj_infoViewModel info, int id)
        {
            // this is how you access the list of errors that can occur during the model binding.
            if (!ModelState.IsValid)
                return View(info);

            var p = projectInfo.GetProjectInfo(id);
            if (p == null)
                return RedirectToAction("Index");

            string projDesc = info._proj_name;
            var  pi = new proj_info
            {
                proj_info_id        =   id,
                proj_name           =   info._proj_name,
                proj_mgr_id         =   info._proj_mgr_id,
                proj_sponsor_id     =   info._proj_sponsor_id,
                charter             =   info._charter,
                scope_definition    =   info._scope_definition,
                dept_id             =   info._dept_id,
                client              =   info._client,
                proj_start_date     =   info._proj_start_date.Value,
                proj_end_date       =   info._proj_end_date,
                proj_status_id      =   info._proj_status_id,
                project_type_id     =   info.proj_type_id,
                createdby           =   User.Identity.Name.Replace("GREENSPOONMARDE\\", ""),
                createddate         =   DateTime.Now,
                notes               =   info._notes,
                proj_goal           =   info._proj_goal,
                doc_location        =   info._doc_location
            };

            var existingProjInfo = _ctx.proj_info.Find(pi.proj_info_id);
            if (existingProjInfo != null)
            {
                // entity already in the context
                var attachedEntry = _ctx.Entry(existingProjInfo);
                attachedEntry.CurrentValues.SetValues(pi);
            }
            _ctx.SaveChanges();
            TempData["ConfirmationMessage"] = pi.proj_name + " has been updated.";
            // I want to redirect here instead of just letting the users sit on the save values on that posted form fields, it is very common after HTTP POST you redirect them back to a page where they
            // can view the changed results, THAT WAY, they don't hit refresh on the result of this post operation and accidentally submit something twice.
            return RedirectToAction("Index", new { searchTerm = projDesc });
        }
コード例 #5
0
        public ActionResult Index(string searchTerm = null, string dropDownList = null)
        {
            var cDescription = string.Empty;
            var result = new proj_infoViewModel();
            var resultStatus = new proj_info();
            try
            {
                switch (dropDownList)
                {
                    case "1":
                        goto default;
                    case "2":
                        cDescription = "StakeHolder";
                        return RedirectToAction("searchStakeholder", new { searchTerm = searchTerm } );
            //                        break;
                    case "3":
                        cDescription = "Status";
                        return RedirectToAction("searchStatus", new { searchTerm = searchTerm });
            //                        break;
                    case "4":
                        cDescription = "Department";
                        return RedirectToAction("searchDepartment", new { searchTerm = searchTerm });
                        //break;
                    default:
                        cDescription = "Project Name";
                        result =
                                (from pi in _ctx.proj_info
                                                    .Include("proj_mgr.proj_sponsor.proj_type.proj_status.dept")
                                 select new proj_infoViewModel
                                 {
                                     _proj_info_id      =   pi.proj_info_id,
                                     _proj_name         =   pi.proj_name,
                                     _proj_mgr_id       =   pi.proj_mgr_id,
                                     _proj_sponsor_id   =   pi.proj_sponsor_id,
                                     _proj_goal         =   pi.proj_goal,
                                     _charter           =   pi.charter.Value,
                                     _scope_definition  =   pi.scope_definition,
                                     proj_type_id       =   pi.project_type_id,
                                     _proj_status_id    =   pi.proj_status_id,
                                     _dept_id           =   pi.dept_id.Value,
                                     _client            =   pi.client,
                                     _proj_start_date   =   pi.proj_start_date,
                                     _proj_end_date     =   pi.proj_end_date,
                                     _notes             =   pi.notes,
                                     _doc_location      =   pi.doc_location,
                                     _createdby         =   pi.createdby,
                                     _createddate       =   pi.createddate
                                 }).FirstOrDefault(r => searchTerm == null || r._proj_name.StartsWith(searchTerm));
                        break;
                }
            }
            catch
            {
                DisplayMessage(searchTerm, cDescription);
            }

            return View(result);
        }
コード例 #6
0
        public ActionResult CreateProject(proj_infoViewModel info)
        {
            string projDesc = info._proj_name;

            if (ModelState.IsValid)
            {
                var p = new proj_info
                {
                    proj_name           = info._proj_name,
                    proj_mgr_id         = info._proj_mgr_id,
                    proj_sponsor_id     = info._proj_sponsor_id,
                    charter             = info._charter,
                    scope_definition    = info._scope_definition,
                    dept_id             = info._dept_id,
                    client              = info._client,
                    proj_start_date     = info._proj_start_date.Value,
                    proj_end_date       = info._proj_end_date,
                    proj_status_id      = info._proj_status_id,
                    project_type_id     = info.proj_type_id,
                    createdby           = info._createdby,
                    createddate         = info._createddate.Value,
                    notes               = info._notes,
                    proj_goal           = info._proj_goal,
                    doc_location        = info._doc_location
                };
                    _ctx.proj_info.Add(p);
                    _ctx.SaveChanges();
                    return RedirectToAction("Index", new { searchTerm = projDesc });

            }

            return View(info);
        }
コード例 #7
0
 // GET Request
 public ActionResult CreateProject()
 {
     proj_infoViewModel projInfo = new proj_infoViewModel
     {
         _proj_name          =   string.Empty,
         _proj_mgr_id        =   1,
         _proj_sponsor_id    =   1,
         _charter            =   false,
         _scope_definition   =   string.Empty,
         _dept_id            =   1,
         _client             =   string.Empty,
         _proj_start_date    =   DateTime.Now,
         _proj_end_date      =   null,
         _proj_status_id     =   1,
         proj_type_id        =   1,
         _createdby          =   User.Identity.Name.Replace("GREENSPOONMARDE\\", ""),
         _createddate        =   DateTime.Now,
         _notes              =   string.Empty,
         _proj_goal          =   string.Empty,
         _doc_location       =   string.Empty
     };
     return PartialView("CreateProject", projInfo);
 }
コード例 #8
0
        public ActionResult Index(string searchTerm = null, string dropDownList = null)
        {
            var cDescription = string.Empty;
            var result       = new proj_infoViewModel();
            var resultStatus = new proj_info();

            try
            {
                switch (dropDownList)
                {
                case "1":
                    goto default;

                case "2":
                    cDescription = "StakeHolder";
                    return(RedirectToAction("searchStakeholder", new { searchTerm = searchTerm }));

//                        break;
                case "3":
                    cDescription = "Status";
                    return(RedirectToAction("searchStatus", new { searchTerm = searchTerm }));

//                        break;
                case "4":
                    cDescription = "Department";
                    return(RedirectToAction("searchDepartment", new { searchTerm = searchTerm }));

                //break;
                default:
                    cDescription = "Project Name";
                    result       =
                        (from pi in _ctx.proj_info
                         .Include("proj_mgr.proj_sponsor.proj_type.proj_status.dept")
                         select new proj_infoViewModel
                    {
                        _proj_info_id = pi.proj_info_id,
                        _proj_name = pi.proj_name,
                        _proj_mgr_id = pi.proj_mgr_id,
                        _proj_sponsor_id = pi.proj_sponsor_id,
                        _proj_goal = pi.proj_goal,
                        _charter = pi.charter.Value,
                        _scope_definition = pi.scope_definition,
                        proj_type_id = pi.project_type_id,
                        _proj_status_id = pi.proj_status_id,
                        _dept_id = pi.dept_id.Value,
                        _client = pi.client,
                        _proj_start_date = pi.proj_start_date,
                        _proj_end_date = pi.proj_end_date,
                        _notes = pi.notes,
                        _doc_location = pi.doc_location,
                        _createdby = pi.createdby,
                        _createddate = pi.createddate
                    }).FirstOrDefault(r => searchTerm == null || r._proj_name.StartsWith(searchTerm));
                    break;
                }
            }
            catch
            {
                DisplayMessage(searchTerm, cDescription);
            }

            return(View(result));
        }