コード例 #1
0
        public ActionResult CoreValues(int taskid, int id, FormCollection form)
        {
            List <Model.DTO.Appraisal.CoreValueComment> lst_comments        = new List <Model.DTO.Appraisal.CoreValueComment>();
            List <Model.DTO.Appraisal.CoreValueComment> lst_delete_comments = new List <Model.DTO.Appraisal.CoreValueComment>();
            Dictionary <string, TempComment>            dict_comments       = new Dictionary <string, TempComment>();

            dict_comments = FormCollectionToDictionary(form);
            string message = string.Empty;

            foreach (KeyValuePair <string, TempComment> kv in dict_comments)
            {
                if (!string.IsNullOrEmpty(kv.Value.CommentContent.Trim()))
                {
                    Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                    {
                        AppraisalCoreValue = new Model.DTO.Appraisal.CoreValue()
                        {
                            Id = Convert.ToInt32(kv.Key)
                        },
                        Comments  = kv.Value.CommentContent.Trim(),
                        Commentor = new Model.DTO.Core.Employee()
                        {
                            Id = CurrentUser.Id
                        },
                        CommentedTimestamp = DateTime.Now,
                        FormSaveOnly       = true
                    };
                    lst_comments.Add(obj_comment);
                }
                else
                {
                    if (!kv.Value.StrCommentID.Contains("NewComment"))
                    {
                        Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                        {
                            Id = Int32.Parse(kv.Value.StrCommentID)
                        };
                        lst_delete_comments.Add(obj_comment);
                    }
                }
            }

            if (!Lib.Utility.Common.IsNullOrEmptyList(lst_comments) || !Lib.Utility.Common.IsNullOrEmptyList(lst_delete_comments))
            {
                if (Model.PMSModel.UpdateAppraisalCoreValueComment(lst_comments, lst_delete_comments, out message))
                {
                    //TempData["AlertMessage"] = "Appraisal information is saved.";
                    return(Redirect(Url.Content("~/Stage2Approval/PerformanceCoachingandReview/" + taskid + "/" + id)));
                }
                else
                {
                    ViewData["appraisalid"]  = id;
                    TempData["AlertMessage"] = "Unable to save Appraisal information. Please try again or contact IT Department.";
                    return(View());
                }
            }
            else
            {
                //TempData["AlertMessage"] = "Appraisal information is saved.";
                return(Redirect(Url.Content("~/Stage2Approval/PerformanceCoachingandReview/" + taskid + "/" + id)));
            }
        }
コード例 #2
0
        public ActionResult CoreValues(int taskid, int id, FormCollection form)
        {
            List<Model.DTO.Appraisal.CoreValueComment> lst_comments = new List<Model.DTO.Appraisal.CoreValueComment>();
            List<Model.DTO.Appraisal.CoreValueComment> lst_delete_comments = new List<Model.DTO.Appraisal.CoreValueComment>();
            Dictionary<string, TempComment> dict_comments = new Dictionary<string, TempComment>();
            dict_comments = FormCollectionToDictionary(form);
            string message = string.Empty;

            foreach (KeyValuePair<string, TempComment> kv in dict_comments)
            {
                if (!string.IsNullOrEmpty(kv.Value.CommentContent.Trim()))
                {
                    Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                    {
                        AppraisalCoreValue = new Model.DTO.Appraisal.CoreValue() { Id = Convert.ToInt32(kv.Key) },
                        //Comments = kv.Value.CommentContent.Trim(),
                        Comments = Lib.Utility.Common.ReplaceLineBreaksForDatabase(Uri.UnescapeDataString(kv.Value.CommentContent.Trim())),
                        Commentor = new Model.DTO.Core.Employee() { Id = CurrentUser.Id },
                        CommentedTimestamp = DateTime.Now,
                        FormSaveOnly = true
                    };
                    lst_comments.Add(obj_comment);
                }
                else
                {
                    if (!kv.Value.StrCommentID.Contains("NewComment"))
                    {
                        Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                        {
                            Id = Int32.Parse(kv.Value.StrCommentID)
                        };
                        lst_delete_comments.Add(obj_comment);
                    }
                }
            }

            if (!Lib.Utility.Common.IsNullOrEmptyList(lst_comments) || !Lib.Utility.Common.IsNullOrEmptyList(lst_delete_comments))
            {
                if (Model.PMSModel.UpdateAppraisalCoreValueComment(lst_comments, lst_delete_comments, out message))
                {
                    //TempData["AlertMessage"] = "Appraisal information is saved.";
                    return Redirect(Url.Content("~/Stage2Approval/PerformanceCoachingandReview/" + taskid + "/" + id));
                }
                else
                {
                    ViewData["appraisalid"] = id;
                    TempData["AlertMessage"] = Resources.Resource.MSG_NEXT_FAIL;
                    return View();
                }
            }
            else
            {
                //TempData["AlertMessage"] = "Appraisal information is saved.";
                return Redirect(Url.Content("~/Stage2Approval/PerformanceCoachingandReview/" + taskid + "/" + id));
            }
        }
コード例 #3
0
        public static void GetCoreValueCommentItemsToSave(string[] result, int commentorId, DateTime commentTimestamp,out List<PMS.Model.DTO.Appraisal.CoreValueComment> lst_comments,out List<PMS.Model.DTO.Appraisal.CoreValueComment> lst_delete_comments)
        {
            lst_comments = null;
            lst_delete_comments = null;
            if (!Lib.Utility.Common.IsNullOrEmptyList(result))
            {
                lst_comments = new List<Model.DTO.Appraisal.CoreValueComment>();
                lst_delete_comments = new List<Model.DTO.Appraisal.CoreValueComment>();
                foreach (string str_string in result)
                {
                    if (!string.IsNullOrEmpty(str_string))
                    {
                        string[] kparray = str_string.Replace("\"", "").Split(',');

                        string tmp_comment = Lib.Utility.Common.ReplaceLineBreaksForDatabase(kparray[1].Split(':')[1].Replace("}]", "").Trim());
                        string tmp_comment_id = kparray[0].Split(':')[1].Trim();

                        if (!string.IsNullOrEmpty(tmp_comment))
                        {
                            PMS.Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                            {
                                AppraisalCoreValue = new Model.DTO.Appraisal.CoreValue() { Id = Convert.ToInt32(kparray[0].Split(':')[1]) },
                                Comments = tmp_comment,
                                FormSaveOnly = true,
                                Commentor = new Model.DTO.Core.Employee() { Id = commentorId },
                                CommentedTimestamp = commentTimestamp
                            };
                            lst_comments.Add(obj_comment);
                        }
                        else
                        {
                            if (!tmp_comment_id.Contains("NewComment"))
                            {
                                PMS.Model.DTO.Appraisal.CoreValueComment obj_comment = new Model.DTO.Appraisal.CoreValueComment()
                                {
                                    AppraisalCoreValue = new Model.DTO.Appraisal.CoreValue() { Id = Convert.ToInt32(kparray[0].Split(':')[1]) },
                                    FormSaveOnly = true,
                                    Commentor = new Model.DTO.Core.Employee() { Id = commentorId },
                                    Id= Int32.Parse(tmp_comment_id)
                                };
                                lst_delete_comments.Add(obj_comment);
                            }
                        }
                    }
                }
            }
            return;
        }