Ejemplo n.º 1
0
 public ActionResult BugReport()
 {
     ModelState.Clear();
     BugReportModel model = new BugReportModel();
     model.BrowserVersion = Request.Browser.Version;
     model.Browser = Request.Browser.Type;
     return View(model);
 }
Ejemplo n.º 2
0
        public ActionResult BugReport(BugReportModel model)
        {
            ModelState.Clear();
            if (model.Summary == null || string.IsNullOrEmpty(model.Summary.Trim()))
            {
                ModelState.AddModelError("Summary", "Необходимо заполнить краткое описание.");
            }
            if (model.Description == null || string.IsNullOrEmpty(model.Description.Trim()))
            {
                ModelState.AddModelError("Description", "Необходимо заполнить подробное описание.");
            }
            if (ModelState.IsValid)
            {
                HttpFileCollectionBase files = Request.Files;

                var guid = Guid.NewGuid();
                if (files != null && files.Count > 0)
                    for (int i = 0; i < files.Count;i++ )
                    {
                        var file = files[i];
                        if (file.ContentLength > 0)
                        {
                            string filename = Path.GetFileName(file.FileName);
                            string path = Path.Combine(Server.MapPath("~/Files"), "..\\Content\\BugReport", guid.ToString());
                            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                            path = Path.Combine(path, filename);
                            file.SaveAs(path);
                        }
                    }

                RequestBl.SendBugReport(model, guid.ToString());
                model = new BugReportModel();
                model.BrowserVersion = Request.Browser.Version;
                model.Browser = Request.Browser.Type;
                ViewBag.Message = "Сообщение отправлено!";
            }
            return View(model);
        }