Exemple #1
0
        public async Task <ResponseMessage> BugReport(BugReportViewModel bug)
        {
            try
            {
                LogThis.BaseLog(Request, LogLevel.Info, Actions.BugReported,
                                new Dictionary <LogProperties, object>
                {
                    { LogProperties.AdditionalData, bug.Bug },
                    { LogProperties.Message, ErrorMessages.Successful }
                });
                _db.BugReports.Add(new BugReport
                {
                    DateTime = DateTime.Now,
                    UserId   = User.Identity.GetUserId(),
                    Text     = bug.Bug
                });
                await _db.SaveChangesAsync();

                return(Tools.ResponseMessage.Ok);
            }
            catch (Exception e)
            {
                LogThis.BaseLog(Request, LogLevel.Error, Actions.BugReported,
                                new Dictionary <LogProperties, object>
                {
                    { LogProperties.Error, e }
                });
                return(Tools.ResponseMessage.InternalError);
            }
        }
        public async Task <ActionResult> BugReport(BugReportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("BugReport", model));
            }

            try
            {
                var report = new BugReport
                {
                    BugTime        = model.BugTime,
                    BugType        = model.BugType,
                    BugDescription = model.BugDescription
                };

                SatChilddb.BugReports.Add(report);
                await SatChilddb.SaveChangesAsync();

                return(RedirectToAction("ThankYou", new { type = "bug" }));
            }
            catch
            {
                return(RedirectToAction("BugReport", model));
            }
        }
        private static BugReportViewModel CopyToBugReportViewModel(this Domain.Entries.ContactUs.BugReports.BugReport bugReport)
        {
            var model = new BugReportViewModel
            {
                Id        = bugReport.Id.ToString(),
                UserEmail = bugReport.Email,
                Category  = new BugReportCategoryViewModel
                {
                    Id          = bugReport.BugReportCategory.Id.ToString(),
                    Index       = bugReport.BugReportCategory.Index,
                    Description = bugReport.BugReportCategory.Description
                },
                Status = new ReportResponseViewModel
                {
                    Id          = bugReport.Status.Id.ToString(),
                    Index       = bugReport.Status.Index,
                    Description = bugReport.Status.Description
                },
                Title    = bugReport.Title,
                Message  = bugReport.Message,
                ImgUrl   = bugReport.ImgUrl,
                DateTime = bugReport.DateTime
            };

            return(model);
        }
Exemple #4
0
        public BugReportPage(BugReportViewModel vm)
        {
            InitializeComponent();

            //TODO: Fix opening links in view model using commands before using the viewmodel
//            DataContext = vm;
        }
Exemple #5
0
        public ActionResult Index(BugReportViewModel model)
        {
            if (!ModelState.IsValid || model == null)
            {
                return(View());
            }

            _service.WriteBugReport(User.Identity.GetUserId(), model.Message);
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public async Task <IActionResult> EditBugReport([FromForm] BugReportViewModel model)
        {
            var result = await _bugReportsService.UpdateBugReportStatus(model, Url);

            if (!result)
            {
                return(RedirectToAction("SomethingWentWrong"));
            }

            return(RedirectToAction("EditBugReport", "Admin", new { bugId = model.Id, updateResult = true }));
        }
        public ActionResult ReportBug(BugReportViewModel vm)
        {
            string output = "";

            if (ModelState.IsValid)
            {
                try
                {
                    vm.Content = vm.Content.Replace(Environment.NewLine, "<br/>");
                    string filename = null;


                    if (vm.BugImage != null)
                    {
                        string path = uploadService.UploadImage(vm.BugImage, WebServices.enums.UploadLocationEnum.Bugs, enableSizeValidation: false);
                        filename = Path.GetFileName(path);
                    }



                    var entity = new BugReport()
                    {
                        Content   = vm.Content,
                        CitizenID = SessionHelper.LoggedCitizen?.ID,
                        Citizen   = SessionHelper.LoggedCitizen,
                        ImgUrl    = filename == null ? null : "upload/" + filename
                    };

                    bugReportRepository.Add(entity);
                    bugReportRepository.SaveChanges();


                    vm.Sent = true;
                }
                catch (Exception e)
                {
                    return(Content(output + "There was a problem with your bug report. Try to go back and save details about bug. Inform admin about this bug by messaging account 'admin'. Try to send bug later. <br/><br/>We are doomed if there are bug errors in bug reporting service :O."
                                   + e.ToString().Replace(Environment.NewLine, "<br/>")
                                   ));
                }
            }
            return(View(vm));
        }
        public ActionResult BugReport()
        {
            var model = new BugReportViewModel
            {
                BugTime  = DateTime.Now.ToLocalTime(),
                BugTypes = new List <BugReportViewModel.BugTypeModel>
                {
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 0, TypeName = "missing pages/broken links"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 1, TypeName = "unable to send message/email"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 2, TypeName = "unable to login"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 3, TypeName = "unable to register"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 4, TypeName = "missing content/pictures"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 5, TypeName = "poor image quality"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 6, TypeName = "visible html/code on pages"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 7, TypeName = "unable to reset password"
                    },
                    new BugReportViewModel.BugTypeModel {
                        TypeId = 8, TypeName = "other"
                    }
                }
            };

            return(View(model));
        }
        public async Task <bool> UpdateBugReportStatus(BugReportViewModel model, IUrlHelper url)
        {
            var report = _context.BugReports
                         .Include(x => x.Status)
                         .FirstOrDefault(x => x.Id == Guid.Parse(model.Id));

            var status = _context.ReportStatus.FirstOrDefault(x => x.Index == model.SelectedStatus);

            if (report is null || status is null)
            {
                return(false);
            }

            report.Status = status;

            _context.BugReports.Update(report);
            await _context.SaveChangesAsync();

            string homePage = url.Action("Index", "Home", new { }, protocol: _httpContextAccessor.HttpContext.Request.Scheme);

            Dictionary <string, string> data = new Dictionary <string, string>()
            {
                { "link", homePage },
                { "message", string.IsNullOrEmpty(model.TextAreaMessage) ? "" : $"Message: {model.TextAreaMessage}" },
                { "status", status.Description }
            };

            var html = await InterpolateDataIntoFile(data);

            var sendEmailResult = await SendMailAsync(model.UserEmail, "Bug report status updated!", html);

            if (!sendEmailResult)
            {
                return(false);
            }

            return(true);
        }