Beispiel #1
0
        public int Add(Comment commentObj, bool doSubmit)
        {
            //triple ensure that the latest comment.PostedOn date is NOT null
            //commentObj.PostedOn = DateTime.Now;
            //Set lastmodified fields
            commentObj.LastModifiedBy = _SessionUsr.ID;
            commentObj.LastModifiedDate = DateTime.Now;

            dbc.Comments.InsertOnSubmit(commentObj);
            if (doSubmit) dbc.SubmitChanges();

            return commentObj.ID; // Return the 'newly inserted id'
        }
Beispiel #2
0
        public int AddEdit(Comment commentObj, bool doSubmit)
        {
            if (commentObj.ID <= Defaults.Integer) // Insert
                return Add(commentObj, doSubmit);

            else // Update
            {
                //Set lastmodified fields
                commentObj.LastModifiedBy = _SessionUsr.ID;
                commentObj.LastModifiedDate = DateTime.Now;

                dbc.Comments.Attach(commentObj);//attach the object as modified
                dbc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, commentObj);//Optimistic-concurrency (simplest solution)
                if (doSubmit) dbc.SubmitChanges();
            }

            return commentObj.ID;
        }
Beispiel #3
0
        public static bool SendEmail(int ClaimID, int AssignTo, string PONumber, Comment CommentObj, ref string Err)
        {
            bool isSelfNotification = (AssignTo == _SessionUsr.ID);
            bool sendMail = (ClaimID > Defaults.Integer && !isSelfNotification);// No need to send mail if its current user
            Err = isSelfNotification ? "Self notification : No email queued" : Err;
            try
            {
                #region Check and send email
                if (sendMail)
                {// No need to send mail if its current user
                    string UserEmail = new UserService().GetUserEmailByID(AssignTo);
                    MailManager.AssignToMail(PONumber, CommentObj.Comment1, ClaimID, UserEmail, (_SessionUsr.UserName), true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                sendMail = false; Err = ex.Message + "<br/>" +
            (ex.InnerException ?? new Exception()).Message;
            }

            return sendMail;
        }
        public JsonResult CommentsKOVM(int ClaimID, string ClaimGUID, int AssignedTo)
        {
            if (_Session.IsOnlyCustomer)
                return Json(null);//Customer doesn't have access to Comments

            //Set Comment object
            Comment newObj = new Comment() { ID = -1, _Added = true, ClaimID = ClaimID, ClaimGUID = ClaimGUID, CommentBy = _SessionUsr.Email, LastModifiedBy = _SessionUsr.ID, LastModifiedDate = DateTime.Now, PostedOn = DateTime.Now, UserID = _SessionUsr.ID, Archived = false };

            #region Kept for testing
            /*
            List<Comment> comments = new List<Comment>();
            try { comments = ((List<Comment>)Session["Comments_Demo"]); }
            catch (Exception ex) { comments = null; }
            bool sendResult = (comments != null && comments.Count() > 0);
            if (sendResult)
                Session.Remove("Comments_Demo");
            */
            #endregion

            DAL.CommentKOModel vm = new CommentKOModel()
            {
                CommentToAdd = newObj, EmptyComment = newObj,
                //AllComments = (sendResult? comments : new CAWcomment(false).Search(ClaimID, null, ClaimGUID)),
                AllComments = new CommentService().Search(ClaimID, null),//(new CAWcomment(false).Search(ClaimID, null, ClaimGUID)),
                AssignedTo = AssignedTo
            };

            vm.Users = new LookupService().GetLookup(LookupService.Source.User);

            return Json(vm, JsonRequestBehavior.AllowGet);
        }
Beispiel #5
0
 public void Delete(Comment commentObj, bool doSubmit)
 {
     dbc.Comments.DeleteOnSubmit(dbc.Comments.Single(c => c.ID == commentObj.ID && c.ClaimID== commentObj.ClaimID));
     if (doSubmit) dbc.SubmitChanges();
 }
Beispiel #6
0
 Comment Transform(Comment c, string commentBy, int claimID)
 {
     return c.Set(c1 => { c1.CommentBy = commentBy;
         /* IMP: NOTE - The following is NOT needed because we've set the Association Access to Internal in the dbml
          c1.Claim = null; c1.ClaimID1 = claimID; */
     });
 }
Beispiel #7
0
		private void detach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.Claim = null;
		}
Beispiel #8
0
		private void attach_Comments(Comment entity)
		{
			this.SendPropertyChanging();
			entity.Claim = this;
		}
Beispiel #9
0
 partial void DeleteComment(Comment instance);
Beispiel #10
0
 partial void UpdateComment(Comment instance);
Beispiel #11
0
 partial void InsertComment(Comment instance);