Ejemplo n.º 1
0
 public void InsertOrUpdate(Comment comment)
 {
     if (comment.ID == default(long)) {
         // New entity
         context.Comments.Add(comment);
     } else {
         // Existing entity
         context.Entry(comment).State = System.Data.Entity.EntityState.Modified;
     }
 }
Ejemplo n.º 2
0
 public ActionResult Edit(Comment comment)
 {
     if (ModelState.IsValid)
     {
         context.Entry(comment).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PossibleTasks = context.Tasks;
     return View(comment);
 }
Ejemplo n.º 3
0
        public ActionResult Create(Comment comment)
        {
            if (ModelState.IsValid)
            {
                context.Comments.Add(comment);
                context.SaveChanges();
                return RedirectToAction("Index");  
            }

            ViewBag.PossibleTasks = context.Tasks;
            return View(comment);
        }
Ejemplo n.º 4
0
        public ActionResult _PostComments(Comment comment)
        {
            if (comment != null)
            {
                comment.ModifiedDate = DateTime.Now;
                comment.CreateDate = DateTime.Now;
                comment.CommentBy = (int)Membership.GetUser(WebSecurity.CurrentUserName).ProviderUserKey;
                //comment.TaskID = 113; //remove it.

                try
                {
                    unitOfWork.CommentRepository.InsertOrUpdate(comment);

                    unitOfWork.Save();

                   
                        Task task = unitOfWork.TaskRepository.Find(comment.TaskID);
                        List<UserProfile> lstInvolvedUser = GetTaskUserOrFollower(comment.TaskID);
                        UserProfile commentby = unitOfWork.UserRepository.GetUserByUserID(comment.CommentBy);
                        string subject = "Comments on task \"" + task.Title + "\"";
                        string body = "<br />" + comment.Message + "";
                        string url = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~") + "/Tasks/Details?id=" + task.TaskID;
                        body += "<br/>Task Title: <a href=\"" + url + "\"target=\"_blank\" shape=\"rect\">" + task.Title + "</a>";
                        body += "<br/>Comment from: " + commentby.FirstName + " " + commentby.LastName;
                        body += "<br /><div><p>We sent you this email because you signed up in PMTool and You are assigned or followed the task. <br /> Please don't reply this mail.</p><p>"
                            + "Regards,<br />PMTool</p></div>";

                        //List of user should be as: to like [email protected]; [email protected];
                        //List of follower should be as in cc like [email protected]; [email protected];
                        //string emailto = String.Empty;
                        //foreach (var user in lstInvolvedUser)
                        //{
                        //    emailto += user.UserName + ";";
                        //}

                        List<string> emailtolist = new List<string>();
                        foreach (var user in lstInvolvedUser)
                        {
                            emailtolist.Add(user.UserName);
                        }

                        if (emailtolist != null)
                            new Thread(() =>
                            {
                            unitOfWork.EmailProcessor.SendEmail("", emailtolist, null, null, subject, body);
                    }).Start();

                    


                    //unitOfWork.EmailProcessor.SendEmail("",user.UserName,
                }
                catch (Exception exp)
                {

                }
            }
            return RedirectToAction("_CommentList", new { @taskId = comment.TaskID });
            //return RedirectToAction("_TaskEntryLog", new { @taskId = timeLog.TaskID });
        }
Ejemplo n.º 5
0
 public PartialViewResult _PostComments(long id) //id = taskId
 {
     Comment comment = new Comment();
     comment.TaskID = id;
     return PartialView(comment);
 }