コード例 #1
0
        // GET /proj_log/Create
        public ActionResult createLog(int id)
        {
            proj_log log = new proj_log
            {
                proj_info_id        = id,
                proj_log_code_id    = 0,
                action_from         = string.Empty,
                action_to           = string.Empty,
                comments            = string.Empty,
                createdby           = User.Identity.Name.Replace("GREENSPOONMARDE\\", ""),
                createddate         = DateTime.Now,
                action_date_from    = null,
                action_date_to      = null
            };

            return PartialView(log);
        }
コード例 #2
0
        public ActionResult createLog(proj_log proj_log, string command)
        {
            string projDesc = projectInfo.returnProjectDescription(proj_log.proj_info_id);

            if (ModelState.IsValid) // the ModelState class encapsulate the state of the model binding, and contains both value and errors. it determine whether any erros were encountered during the model binding.
            {
                _ctx.proj_log.Add(proj_log);
                _ctx.SaveChanges();

                // Allows you to store data that will survive for a redirect. Internally it uses the Session as baking store, it's just that after the redirect is made the data is automatically evicted
                //TempData["ConfirmationMessage"] = proj_log.proj_info_id + " has been added";
                return RedirectToAction("Index", new { searchTerm = projDesc });
            }

            return View(proj_log);
        }