Example #1
0
        public async Task <Result <BugTicketManageModel> > GetBugTicket(int id)
        {
            if (id == 0)
            {
                return(new BugTicketManageModel(null)
                {
                    PublicId = Guid.NewGuid(),
                    StatusCode = BugTicketStatus.Active,
                    Priority = TicketPriority.Low,
                    IsAllowEdit = true,
                    Comments = new List <BugTicketCommentManageModel>(),
                    Files = new List <FileModel>(),
                });
            }

            var result = await _helpService.GetBugTicketAsync(id);

            var toReturn = new BugTicketManageModel(result);

            var superAdmin = _referenceData.AdminRoles.Single(x => x.Key == (int)RoleType.SuperAdminUser).Text;

            if (HttpContext.User.IsInRole(superAdmin.Normalize()) || result.IdAddedBy == Int32.Parse(_userManager.GetUserId(User)))
            {
                toReturn.IsAllowEdit = true;
            }

            return(toReturn);
        }