예제 #1
0
        public JsonResult Create([FromBody] IssueLogListingModelForAjax issueLogListingModel)
        {
            if (ModelState.IsValid)
            {
                List <string> involvedPersonIds = new List <string>();
                if (!string.IsNullOrEmpty(issueLogListingModel.IssueLogInvolvedPersonIds))
                {
                    involvedPersonIds = issueLogListingModel.IssueLogInvolvedPersonIds.Split(',').ToList();
                }
                var userId          = _userManager.GetUserId(User);
                var user            = _userManager.FindByIdAsync(userId).Result;
                var involvedPersons = new List <ApplicationUser>();
                if (involvedPersonIds.Count() > 0)
                {
                    involvedPersons = _userManager.Users.Where(x => involvedPersonIds.Contains(x.Id)).ToList();
                }
                involvedPersons.Add(user);
                var issueLog = BuildIssueLogForCreate(issueLogListingModel, user, involvedPersons);
                _issueLogService.Create(issueLog);
                foreach (var p in issueLog.IssueLogInvolvedPersons.Where(x => x.InvolvedPerson.Id != user.Id))
                {
                    var notification = new Notification
                    {
                        UserFrom      = user.Id,
                        UserFromImage = user.ProfileImageUrl,
                        UserTo        = p.InvolvedPerson.Id,
                        Header        = issueLog.Project.Name + "(" + issueLog.Project.Company.Name + ")",
                        Message       = issueLog.Header,
                        IsRead        = false
                    };
                    _notificationService.Create(notification);
                }
                //var smtpClient = new SmtpClient
                //{
                //    Host = "smtp.gmail.com", // set your SMTP server name here
                //    Port = 587, // Port
                //    EnableSsl = true,
                //    Credentials = new NetworkCredential("*****@*****.**", "SBsb@@##942681992fuckyouGetVirusSBsb@@##942681992fuckyou")
                //};

                //using (var message = new MailMessage("*****@*****.**", "*****@*****.**")
                //{
                //    Subject = "Subject",
                //    Body = "Body"
                //})
                //{
                //    smtpClient.SendMailAsync(message);
                //}
                return(Json(new
                {
                    redirectTo = Url.Action("Index", "IssueLog")
                }));
            }
            return(Json(new
            {
                redirectTo = Url.Action("Index", "IssueLog"),
            }));
        }
예제 #2
0
        public async Task <IActionResult> View(IssueLogInvolvedPersonListingModel model)
        {
            var issuelogInvolvedPerson = _involvedPersonService.GetById(model.Id);
            var userId       = _userManager.GetUserId(User);
            var user         = _userManager.FindByIdAsync(userId).Result;
            var notification = new Notification();

            if (model.IsStart)
            {
                issuelogInvolvedPerson.ReceiveDate  = DateTime.Now;
                issuelogInvolvedPerson.ExpectedHour = model.ExpectedHour;

                notification = new Notification
                {
                    UserFrom      = user.Id,
                    UserFromImage = user.ProfileImageUrl,
                    UserTo        = issuelogInvolvedPerson.IssueLog.EntryBy.Id,
                    Header        = issuelogInvolvedPerson.IssueLog.Project.Name + "(" + issuelogInvolvedPerson.IssueLog.Project.Company.Name + ")",
                    Message       = user.UserName + " has started working on " + issuelogInvolvedPerson.IssueLog.Header + ". Expected Hour is " + model.ExpectedHour,
                    IsRead        = false
                };
            }
            else
            {
                issuelogInvolvedPerson.IsComplete      = true;
                issuelogInvolvedPerson.HoursToComplete = model.HoursToComplete;
                issuelogInvolvedPerson.SubmitDate      = DateTime.Now;

                notification = new Notification
                {
                    UserFrom      = user.Id,
                    UserFromImage = user.ProfileImageUrl,
                    UserTo        = issuelogInvolvedPerson.IssueLog.EntryBy.Id,
                    Header        = issuelogInvolvedPerson.IssueLog.Project.Name + "(" + issuelogInvolvedPerson.IssueLog.Project.Company.Name + ")",
                    Message       = user.UserName + " has completed this task - " + issuelogInvolvedPerson.IssueLog.Header + ". Time taken : " + model.HoursToComplete + " hours",
                    IsRead        = false
                };
            }
            await _involvedPersonService.UpdateIssueLog(issuelogInvolvedPerson);

            _notificationService.Create(notification);
            return(RedirectToAction("Index", "InvolvedPerson", new { id = 0 }));
        }