Beispiel #1
0
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="CommentId"></param>
        /// <returns></returns>
        public Message Insert(JobRequestComment objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    // Set more info

                    dbContext.JobRequestComments.InsertOnSubmit(objUI);
                    dbContext.SubmitChanges();

                    // Show success message
                    msg = new Message(MessageConstants.I0001, MessageType.Info, objUI.Poster,"added a comment");
                }
            }
            catch
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
Beispiel #2
0
        public Message UpdateForApproval(JobRequest objUI, JobRequestComment objComment)
        {
            Message msg = null;
            DbTransaction trans = null;

            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;
                if (objUI != null)
                {
                    JobRequest objDb = GetById(objUI.ID);
                    if (objDb != null)
                    {
                        #region Insert Comment
                        if (objComment != null && !string.IsNullOrEmpty(objComment.Contents))
                        {
                            JRCommentDao commentDao = new JRCommentDao();
                            commentDao.Insert(objComment);
                        }
                        #endregion
                        // Check valid update date
                        if (IsValidUpdateDate(objUI, objDb, out msg))
                        {
                            new JobRequestLogDao().WriteUpdateLogForRoleManager(objUI, ELogAction.Update);
                            objDb.WFResolutionID = objUI.WFResolutionID;
                            //if (!string.IsNullOrEmpty(objUI.Approval))
                            //{
                            //    objDb.Approval = objUI.Approval;
                            //}
                            objDb.WFResolution = objUI.WFResolution;
                            objDb.AssignID = objUI.AssignID;
                            objDb.AssignRole = objUI.AssignRole;
                            objDb.InvolveID = objUI.InvolveID;
                            objDb.InvolveRole = objUI.InvolveRole;
                            objDb.InvolveDate = objUI.InvolveDate;
                            objDb.UpdateDate = DateTime.Now;
                            dbContext.SubmitChanges();

                            msg = new Message(MessageConstants.I0001, MessageType.Info, " Job Request '" + Constants.JOB_REQUEST_PREFIX + objUI.ID + "'", "updated");
                            trans.Commit();
                        }
                        else
                        {
                            trans.Rollback();
                        }
                    }
                }
            }
            catch
            {
                // Rollback transaction
                if (trans != null)
                {
                    trans.Rollback();
                }
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            finally
            {
                if ((trans.Connection != null) && (trans.Connection.State == System.Data.ConnectionState.Open))
                {
                    trans.Connection.Close();
                }
            }
            return msg;
        }