public ActionResult RateIssue(IssueDetailsViewModel issueDetails)
        {
            Issue issue = db.Issues.Find(issueDetails.Id);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            issue.Rate        = issueDetails.Rate;
            issue.RateComment = issueDetails.CommentRate;
            issue.State       = 2;
            issue.EndDate     = DateTime.Now;
            db.SaveChanges();
            var userMails = new List <string>();
            var userId    = User.Identity.GetUserId();

            userMails.Add(db.Users.First(u => u.Id == userId).Email);
            var type = db.Types.First(t => t.Id == issue.TypeId);

            foreach (var user in type.Users)
            {
                userMails.Add(user.Email);
            }
            SendMail.InformUsers(userMails, issue, User.Identity.Name, "", 4);
            TempData["Success"] = "Usterka została oceniona i przeniesiona do archiwum!";
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult AddComment(IssueDetailsViewModel issueDetails)
        {
            Issue issue = db.Issues.Find(issueDetails.Id);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            var comm = new Comment();

            comm.UserId  = User.Identity.GetUserId();
            comm.Content = issueDetails.CommentContent;
            comm.Date    = DateTime.Now;
            issue.Comments.Add(comm);
            db.SaveChanges();
            var userMails = new List <string>();
            var userId    = User.Identity.GetUserId();

            userMails.Add(db.Users.First(u => u.Id == userId).Email);
            var type = db.Types.First(t => t.Id == issue.TypeId);

            foreach (var user in type.Users)
            {
                userMails.Add(user.Email);
            }
            SendMail.InformUsers(userMails, issue, User.Identity.Name, comm.Content, 2);
            TempData["Success"] = "Dodano nowy komentarz!";
            return(RedirectToAction("Details", "Issue", new { id = issueDetails.Id }));
        }
 public IssueDetailsPage(Guid issueId)
 {
     NavigationPage.SetBackButtonTitle(this, "");
     //HockeyApp.MetricsManager.TrackEvent("IssueDetailsPage Initialize");
     InitializeComponent();
     viewModel             = new IssueDetailsViewModel();
     viewModel.VisibleLoad = true;
     BindingContext        = viewModel;
     GetObicen(issueId);
 }
示例#4
0
        // GET: Issues/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Issue issue = db.Issues.Find(id);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            IssueDetailsViewModel vm = new IssueDetailsViewModel(issue);

            return(View(vm));
        }
        public ActionResult IssueDone(IssueDetailsViewModel issueDetails)
        {
            Issue issue = db.Issues.Find(issueDetails.Id);

            if (issue == null)
            {
                return(HttpNotFound());
            }
            issue.State = 1;
            db.SaveChanges();
            var userMails = new List <string>();
            var userId    = User.Identity.GetUserId();

            userMails.Add(db.Users.First(u => u.Id == userId).Email);
            var type = db.Types.First(t => t.Id == issue.TypeId);

            SendMail.InformUsers(userMails, issue, "", "", 3);
            TempData["Success"] = "Usterka została wykonana. Użytkownik został poinformowany!";
            return(RedirectToAction("Index", "Home"));
        }
示例#6
0
        public ActionResult Comment([Bind(Include = "IssueID,NewCommentText")] IssueDetailsViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Details", vm));
            }
            if (vm.IssueID == 0)
            {
                throw new ArgumentException("The IssueID cannot be 0.");
            }

            Issue i = db.Issues.Find(vm.IssueID);

            if (i == null)
            {
                throw new KeyNotFoundException(String.Format("The issue for ID {0} was not found.", vm.IssueID));
            }

            AddIssueComment(vm.NewCommentText, i);

            return(RedirectToAction("Details", "Issues", new { id = vm.IssueID }));
        }
        public ActionResult DownloadAttachment(IssueDetailsViewModel attachment)
        {
            var fileId = attachment.Issue.FileId;
            var file   = db.Files.FirstOrDefault(f => f.Id == fileId);

            if (file != null)
            {
                string filename    = file.FileName;
                byte[] filedata    = file.Content;
                string contentType = file.ContentType;

                var cd = new System.Net.Mime.ContentDisposition
                {
                    FileName = filename,
                    Inline   = true,
                };

                Response.AppendHeader("Content-Disposition", cd.ToString());

                return(File(filedata, contentType));
            }
            TempData["Fail"] = "Taki plik nie istnieje w bazie!";
            return(RedirectToAction("Details", "Issue", new { id = attachment.Id }));
        }
        public IssueDetailsPage(IssueDetailsViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }
示例#9
0
        public async Task <IActionResult> IssueDetails(IssueDetailsViewModel model)
        {
            var userId      = userManager.GetUserId(User);
            var currentUser = await userManager.FindByIdAsync(userId);

            var userClaims = await userManager.GetClaimsAsync(currentUser);

            Global.globalCurrentUserClaims = userClaims.ToList();

            var IsManagerLevel = ClaimsLevel.IsManager(userClaims.ToList(), model.Issue.AssociatedProject);

            if (IsManagerLevel && model.Issue.AssigneeUserId != null)
            {
                var assignedUser = await userManager.FindByIdAsync(model.Issue.AssigneeUserId);

                model.Issue.AssigneeUserName = assignedUser.UserName;
            }

            var uniqueFileNames = new List <ScreenShots>();

            if (Global.InitialScreenShots == true)
            {
                uniqueFileNames = await UploadScreenShotsToStorage(model.Issue.IssueId);
            }

            Global.InitialScreenShots = false;
            _issueRepository.AddScreenShots(uniqueFileNames);


            var originalIssue = _issueRepository.GetIssue(model.Issue.IssueId);

            if (model.Issue.Title == null)
            {
                model.Issue.Title = originalIssue.Title;
            }

            var IsDeveloperLevel = ClaimsLevel.IsDeveloper(userClaims.ToList(), model.Issue.AssociatedProject);

            if (IsDeveloperLevel)
            {
                foreach (var property in originalIssue.GetType().GetProperties())
                {
                    if (property.Name == "AssigneeUserId")
                    {
                        continue;
                    }

                    var oldValue = "";
                    var newValue = "";

                    if (property.GetValue(model.Issue) != null)
                    {
                        newValue = property.GetValue(model.Issue).ToString();
                    }

                    if (property.GetValue(originalIssue) != null)
                    {
                        oldValue = property.GetValue(originalIssue).ToString();
                    }

                    if (newValue != oldValue)
                    {
                        var changes = new IssueHistory
                        {
                            AssociatedIssueId = originalIssue.IssueId,
                            DateModified      = DateTime.Now,
                            NewValue          = newValue,
                            OldValue          = oldValue,
                            Property          = property.Name
                        };

                        _issueRepository.AddIssueHistory(changes);
                    }
                }
            }

            var issue = new Issue();

            if (IsDeveloperLevel)
            {
                model.Issue.ScreenShots = uniqueFileNames;
                model.Issue.ScreenShots.AddRange(_issueRepository.ScreenShots(model.Issue.IssueId));
                issue = _issueRepository.Update(model.Issue);
            }
            else
            {
                issue             = originalIssue;
                issue.ScreenShots = uniqueFileNames;
                issue.ScreenShots.AddRange(_issueRepository.ScreenShots(model.Issue.IssueId));
            }
            Console.WriteLine(issue.IssueId);
            var project     = _projectRepository.GetProject(issue.AssociatedProject);
            var projectName = project.ProjectName;

            issue.Comments = _issueRepository.Comments(issue.IssueId);
            var issueHistory = _issueRepository.GetIssueHistories(issue.IssueId);

            var users        = new List <IdentityUser>();
            var projectUsers = new List <string>();

            projectUsers.Add(project.OwnerId);

            if (project.UsersAssigned != null)
            {
                projectUsers.AddRange(project.UsersAssigned.Split(" ").ToList());
            }

            foreach (var uId in projectUsers)
            {
                var user = await userManager.FindByIdAsync(uId);

                if (user != null && !users.Contains(user))
                {
                    users.Add(user);
                }
            }

            var screenshots = _issueRepository.ScreenShots(model.Issue.IssueId);


            var viewModel = new IssueDetailsViewModel
            {
                Issue          = issue,
                IssueHistories = issueHistory,
                Updated        = 1,
                ProjectId      = issue.AssociatedProject,
                Source         = screenshots,
                ProjectUsers   = users,
                ProjectName    = projectName
            };

            return(View(viewModel));
        }
示例#10
0
        public async Task <IActionResult> IssueDetails(int issueId)
        {
            var issue = _issueRepository.GetIssue(issueId);

            Global.ProjectId = issue.AssociatedProject;

            var project = _projectRepository.GetProject(issue.AssociatedProject);

            Global.Project = project;

            var userId      = userManager.GetUserId(User);
            var currentUser = await userManager.FindByIdAsync(userId);

            var userClaims = await userManager.GetClaimsAsync(currentUser);

            Global.globalCurrentUserClaims = userClaims.ToList();

            var IsUserLevel = ClaimsLevel.IsUser(userClaims.ToList(), issue.AssociatedProject);

            if (IsUserLevel == false)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            var screenshots  = _issueRepository.ScreenShots(issueId);
            var projectName  = project.ProjectName;
            var comments     = _issueRepository.Comments(issueId);
            var issueHistory = _issueRepository.GetIssueHistories(issueId);

            issue.Comments = comments;

            var users        = new List <IdentityUser>();
            var projectUsers = new List <string>();

            projectUsers.Add(project.OwnerId);

            if (project.UsersAssigned != null)
            {
                projectUsers.AddRange(project.UsersAssigned.Split(" ").ToList());
            }

            foreach (var uId in projectUsers)
            {
                var user = await userManager.FindByIdAsync(uId);

                if (user != null && !users.Contains(user))
                {
                    users.Add(user);
                }
            }

            var viewModel = new IssueDetailsViewModel
            {
                Issue           = issue,
                IssueHistories  = issueHistory,
                ProjectId       = issue.AssociatedProject,
                CurrentUserName = User.Identity.Name,
                ProjectName     = project.ProjectName,
                ProjectUsers    = users,
                Source          = screenshots,
                Updated         = 0
            };

            return(View(viewModel));
        }
示例#11
0
        public ActionResult Details(int?id)
        {
            if (User.Identity.OneTimePassword())
            {
                return(RedirectToAction("ChangePassword", "Manage"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Issue issue = db.Issues.Find(id);
            var   rate  = new List <int>()
            {
                1, 2, 3, 4, 5, 6
            };

            if (issue == null)
            {
                return(HttpNotFound());
            }
            if (!CheckPermissions(issue))
            {
                TempData["Fail"] = "Nie posiadasz uprawnień do edycji tej usterki!";
                return(RedirectToAction("Index", "Home"));
            }

            var issueDetails = new IssueDetailsViewModel();

            issueDetails.Issue = issue;
            foreach (var item in issueDetails.Issue.Comments)
            {
                var comment = new CommentsViewModel();
                comment.Content = item.Content;
                comment.Date    = item.Date;
                if (db.Users.Single(u => u.Id == item.UserId) != null)
                {
                    comment.UserName = db.Users.Single(u => u.Id == item.UserId).UserName;
                }
                else
                {
                    comment.UserName = "******";
                }
                issueDetails.Comments.Add(comment);
            }
            if (issue.State == 2)
            {
                issueDetails.TimeExpired = String.Format("{0:%d}d {0:%h}g {0:%m}m {0:%s}s", issue.EndDate - issue.StartDate);
            }
            issueDetails.Rates = rate.Select(c => new SelectListItem {
                Text = c.ToString(), Value = c.ToString()
            });
            issueDetails.CommentRate = "Usterka naprawiona";
            issueDetails.Id          = issue.Id;
            issueDetails.Type        = db.Types.First(t => t.Id == issue.TypeId);
            issueDetails.UserId      = User.Identity.GetUserId();
            if (issue.FileId != 0)
            {
                var attachment = db.Files.FirstOrDefault(f => f.Id == issue.FileId);
                if (attachment != null)
                {
                    issueDetails.Attachment = attachment;
                }
            }
            return(View(issueDetails));
        }
        private async Task <bool> GetIssues(Guid issueId)
        {
            try
            {
                var issue = await IssuesService.client.GetAsync(issueId, modelProperties : new ProjectInsight.Models.Base.ModelProperties("default,IssueType,UserAssignedTo_Id,ProjectAffiliation_Id,IssueStatusType,WorkPercentCompleteType,DescriptionText,Description,UserAssignedTo,Severity,UserAssignedBy,FoundBy,FoundDateTimeUTC,IssuePriority,IssueSeverity,ProjectResolution,ProjectAffiliation;Project:ItemNumberFullAndNameDisplayPreference"));



                if (issue != null)
                {
                    var item = new IssueDetailsViewModel
                    {
                        Id                = issue.Id.ToString(),
                        Name              = issue.Name,
                        ProjectName       = issue.ProjectAffiliation != null ? issue.ProjectAffiliation.ItemNumberFullAndNameDisplayPreference : "",
                        FoundBy           = issue.FoundBy,
                        StartDate         = issue.StartDateTimeUTC.Value,
                        EndDate           = issue.EndDateTimeUTC,
                        StatusType        = issue.IssueStatusType,
                        UserAssignedTo_Id = issue.UserAssignedTo_Id,
                        Project_Id        = issue.ProjectAffiliation_Id

                                            //FoundDate = issue.FoundDateTimeUTC != null ? issue.FoundDateTimeUTC.Value :
                    };

                    // viewModel.WorkStatus = item.WorkPercentCompleteType != null ? item.WorkPercentCompleteType.Name : "";
                    // viewModel.WorkPercentCompleteType = item.WorkPercentCompleteType;

                    if (issue.UserAssignedTo != null)
                    {
                        item.UserAssignedTo = "Assigned To: " + issue.UserAssignedTo.FirstName + " " + issue.UserAssignedTo.LastName;
                    }

                    if (issue.UserAssignedBy != null)
                    {
                        item.UserAssignedBy = "Assigned By: " + issue.UserAssignedBy.FirstName + " " + issue.UserAssignedBy.LastName;
                    }

                    if (issue.IssuePriority != null)
                    {
                        item.Priority = "Priority By: " + issue.IssuePriority.Name;
                    }

                    if (issue.IssueSeverity != null)
                    {
                        item.Severity = "Severity: " + issue.IssueSeverity.Name;
                    }

                    if (issue.DescriptionText != null)
                    {
                        item.Description = issue.DescriptionText;
                    }



                    viewModel             = item;
                    viewModel.VisibleLoad = false;
                    BindingContext        = viewModel;
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }