Exemple #1
0
        public async Task <IActionResult> Create(ItemEntity item, string comment)
        {
            try
            {
                var ads = new ItemEntity
                {
                    Project = new ProjectEntity()
                };
                //TODO
                //if (!ModelState.IsValid) return View(item);

                var itemId = _itemRepo.Add(item);

                if (!string.IsNullOrEmpty(comment))
                {
                    var commentEntity = new ItemCommentsEntity();
                    commentEntity.Comment = comment;
                    commentEntity.Item    = item;
                    commentEntity.CreUser = await CurrentUser;
                    _commentRepo.Add(commentEntity);
                }

                _logRepo.LogInfo($"{item.Title} Saved.", Request.Path, Microsoft.Extensions.Logging.LogLevel.Information);

                var user = await _userManager.FindByIdAsync(item.AssignedUser.Id);

                if (user != null)
                {
                    var email = user.Email;

                    await MailHelper.SendMailAsync("BUG CATCHER", "Yeni bir item atandı.", null, itemId, user.Email);
                }

                Response.Redirect("/" + Url.FriendlyUrl(item.Title) + "/" + item.Id);
                return(View(item));
            }
            catch (Exception ex)
            {
                _logRepo.LogError(ex, Request.Path, Microsoft.Extensions.Logging.LogLevel.Error);
                return(View());
            }
        }
Exemple #2
0
        public async Task <IActionResult> Edit(ItemEntity item, string comment)
        {
            try
            {
                //TODO
                //if (!ModelState.IsValid) return View(item);

                TempData["ItemId"] = item.Id;
                _itemRepo.Update(item);

                if (!string.IsNullOrEmpty(comment))
                {
                    var commentEntity = new ItemCommentsEntity();
                    commentEntity.Comment = comment;
                    commentEntity.Item    = item;
                    commentEntity.CreUser = await CurrentUser;
                    _commentRepo.Add(commentEntity);

                    _logRepo.LogInfo($"{item.Title} Edited.", Request.Path, Microsoft.Extensions.Logging.LogLevel.Information);
                }

                var user = await _userManager.FindByIdAsync(item.AssignedUser.Id);

                if (user != null)
                {
                    await MailHelper.SendMailAsync("BUG CATCHER", $"{item.Title}", null, item.Id, user.Email);
                }

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                _logRepo.LogError(ex, Request.Path, Microsoft.Extensions.Logging.LogLevel.Error);
                return(View(item));
            }
        }