Example #1
0
        public ActionResult CreateBug(string projectUrlName)
        {
            BugsModel bugsModel     = new BugsModel();
            Guid      liveProjectId = RetrieveCollectionOfProjects().Where(p => p.UrlName == projectUrlName).SingleOrDefault().Id;

            bugsModel.SystemParentId = liveProjectId;

            return(View("BugForm", bugsModel));
        }
 public ActionResult Index(BugsModel bug)
 {
     if (ModelState.IsValid)
     {
         ViewBag.Message = "Bug is added";
     }
     else
     {
         ViewBag.Message = "Fail";
     }
     return(View());
 }
Example #3
0
 public ActionResult BugDetails(Guid id)
 {
     try
     {
         MongoCRUD db = new MongoCRUD("BZBugs");
         BugsModel details = db.LoadRecordById<BugsModel>("Bugs", id);
         return View(details);             
     }
     catch
     {
         return RedirectToAction(nameof(ListBugs));
     }         
 }
        public void GetAllBugsServiceShouldCallGateway()
        {
            //Arrange
            var model = new BugsModel()
            {
            };


            //Act
            _bugsService.GetAllBugs();

            //Assert
            _bugsGatewayMock.Verify(m => m.GetAllBugs(), Times.Once);
        }
 public IActionResult Post([FromBody] BugsModel value)
 {
     try
     {
         value.Author = new UserModel {
         };
         DbContext.Database.EnsureCreated();
         DbContext.Bugs.Add(value);
         DbContext.SaveChanges();
     }
     catch (SqlException exception)
     {
         Console.WriteLine(exception.ToString());
         return(StatusCode(500));
     }
     return(Accepted());
 }
        public void GetBugShouldReturnResultsMatchingObject()
        {
            var model = new BugsModel()
            {
                Status      = "new",
                Description = "test"
            };

            //Arrange
            _bugsGatewayMock.Setup(_ => _.GetBug(It.IsAny <int>())).ReturnsAsync(model);


            //Act
            var results = _bugsService.GetBug(It.IsAny <int>());

            //Assert
            Assert.Equal(results, model);
        }
Example #7
0
        public ActionResult CreateBug(BugsModel bug)
        {
            DynamicContent masterProject = DynamicModuleManager.GetDataItem(projectsType, bug.SystemParentId);

            var newBug = dynamicModuleManager.CreateDataItem(bugType);

            newBug.SetValue("Title", bug.Title);
            newBug.UrlName = Regex.Replace(bug.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
            newBug.SetValue("Description", bug.Description);
            newBug.SetValue("SystemParentId", masterProject.OriginalContentId);
            newBug.ApprovalWorkflowState = "Published";

            DynamicModuleManager.Lifecycle.Publish(newBug);

            DynamicModuleManager.SaveChanges();

            return(RedirectToAction("Detail", new { urlName = masterProject.UrlName }));
        }
        public async Task <ActionResult> CreateBug(BugsModel bug)
        {
            if (bug == null)
            {
                return(new StatusCodeResult(400));
            }
            try
            {
                HttpResponseMessage response = await _client.PostAsJsonAsync(_configuration.Value.AirLogicApiBaseUrl + "/api/Bugs", bug);

                response.EnsureSuccessStatusCode();
                return(new StatusCodeResult(200));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(new StatusCodeResult(500));
            }
        }
Example #9
0
 public ActionResult Edit(Guid id, BugsModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             MongoCRUD db = new MongoCRUD("BZBugs");
             db.UpsertRecord("Bugs", id, model);
             return RedirectToAction(nameof(ListBugs));
         }
         else
         {
             return View("EditBug", model);
         }
     }
     catch
     {
         return View("EditBug");
     }
 }
Example #10
0
 public ActionResult Create(BugsModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             MongoCRUD db = new MongoCRUD("BZBugs");
             db.InsertRecord("Bugs", model);
             return RedirectToAction(nameof(ListBugs));
         }
         else
         {
             return View("CreateBug", model);
         }
         
     }
     catch
     {
         return View();
     }
 }
Example #11
0
        public ActionResult CreateBug(BugsModel bug)
        {
            bug.AssignedFlag = new AssignedStatus()
            {
                Assigned     = true,
                AssignedUser = new UserModel()
                {
                    Username   = "******",
                    FirstName  = "Mohammed",
                    Department = "it"
                }
            };

            bug.Author = new UserModel()
            {
                Username   = "******",
                FirstName  = "Mohammed",
                Department = "it"
            };

            var result = _bugsGateway.CreateBug(bug);

            return(result.Result);
        }
        // GET: Bugs
        public ActionResult ReportBug(long BugId = 0)
        {
            var       client = new HttpClient();
            BugsModel model  = new BugsModel();

            if (BugId > 0)
            {
                model.BugId     = BugId;
                model.Mode      = "Edit";
                model.UserId    = 0;
                model.ProjectId = 0;
                var serialized = JsonConvert.SerializeObject(model);
                var content    = new StringContent(serialized, System.Text.Encoding.UTF8, "application/json");
                client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
                var result = client.PostAsync(BaseURL + "/api/Bugs/GetBugDetails", content).Result;
                if (result.StatusCode == HttpStatusCode.OK)
                {
                    var contents = result.Content.ReadAsStringAsync().Result;
                    var Response = JsonConvert.DeserializeObject <List <BugsModel> >(contents);
                    if (Response.Count > 0)
                    {
                        model = Response.FirstOrDefault();
                    }
                }
            }
            client             = new HttpClient();
            client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
            var Clientresult = client.GetAsync(BaseURL + "/api/Bugs/GetEmployees").Result;

            if (Clientresult.StatusCode == HttpStatusCode.OK)
            {
                var contents = Clientresult.Content.ReadAsStringAsync().Result;
                var response = new JavaScriptSerializer().Deserialize <List <EmployeesDomainModel> >(contents);
                model.listEmployees = response;
            }
            var ClientResult1 = client.GetAsync(BaseURL + "/api/Project/GetProjectList").Result;

            if (ClientResult1.StatusCode == HttpStatusCode.OK)
            {
                var contents = ClientResult1.Content.ReadAsStringAsync().Result;
                var response = new JavaScriptSerializer().Deserialize <List <ProjectDomainModel> >(contents);
                model.listProjects = response;
            }
            var listPriority = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "High", Value = "High"
                },
                new SelectListItem {
                    Text = "Low", Value = "Low"
                },
                new SelectListItem {
                    Text = "Urgent", Value = "Urgent"
                },
                new SelectListItem {
                    Text = "Immediate", Value = "Immediate"
                }
            };
            var listStatus = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "New", Value = "New"
                },
                new SelectListItem {
                    Text = "ReOpened", Value = "ReOpened"
                },
                new SelectListItem {
                    Text = "Closed", Value = "Closed"
                }
            };

            ViewData["ddlPriority"] = listPriority;
            ViewData["ddlStatus"]   = listStatus;
            ViewBag.Class           = "display-hide";
            return(View(model));
        }
        public ActionResult ReportBug(BugsModel model)
        {
            ViewBag.Class = "display-hide";
            var client = new HttpClient();

            try
            {
                if (ModelState.IsValid)
                {
                    model.Files         = "";
                    model.BugReportedBy = UserManager.user.UserId;
                    HttpPostedFileBase[] PostedFiles = model.PostedFiles;
                    model.PostedFiles = null;
                    var serialized = JsonConvert.SerializeObject(model);
                    var content    = new StringContent(serialized, System.Text.Encoding.UTF8, "application/json");
                    client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
                    var result = client.PostAsync(BaseURL + "/api/Bugs/AddUpdateBug", content).Result;
                    if (result.StatusCode == HttpStatusCode.OK)
                    {
                        var contents = result.Content.ReadAsStringAsync().Result;
                        var Response = JsonConvert.DeserializeObject <ResponseModel>(contents);
                        if (Response.isSuccess == true)
                        {
                            if (Response.response == "Bug added successfully.")
                            {
                                //String Email = GetUserEmail(model.UserId);
                                ////Session["Email1"] = Email;
                                ////Session["ProjectName"] = model.ProjectId;
                                ////Session["Bugsubject"] = model.BugSubject;
                                //Thread threadSendMails;

                                //threadSendMails = new Thread(delegate ()
                                //{
                                //    //SendEmail(Session["Email1"].ToString(), Session["ProjectName"].ToString(), Session["Bugsubject"].ToString());
                                //    SendEmail(Email, GetProjectTitle(model.ProjectId), model.BugSubject.ToString());

                                //});
                                //threadSendMails.IsBackground = true;

                                //threadSendMails.Start();

                                string insertfile = string.Empty;
                                foreach (HttpPostedFileBase file in PostedFiles)
                                {
                                    if (file != null)
                                    {
                                        Guid   g1             = Guid.NewGuid();
                                        string ext            = System.IO.Path.GetExtension(file.FileName);
                                        string fileName       = g1 + ext;
                                        var    ServerSavePath = Path.Combine(Server.MapPath("~/BugUploadDocument/") + fileName);
                                        file.SaveAs(ServerSavePath);
                                        insertfile = AddBugFiles(fileName);
                                    }
                                }
                                if (insertfile != null)
                                {
                                    if (insertfile == "InsertImage")
                                    {
                                    }
                                }
                                ModelState.Clear();
                                ModelState.AddModelError("CustomError", Response.response);
                                ViewBag.Class = "alert-success";
                                model         = new BugsModel();
                            }
                            else if (Response.response == "Bug updated successfully.")
                            {
                                //if (model.Status == "ReOpened")
                                //{
                                //    String Email = GetUserEmail(model.UserId);
                                //    //Session["Email1"] = Email;
                                //    //Session["ProjectName"] = model.ProjectId;
                                //    //Session["Bugsubject"] = Convert.ToString(model.BugSubject);
                                //    Thread threadSendMails;

                                //    threadSendMails = new Thread(delegate ()
                                //    {
                                //        //SendEmail(Session["Email1"].ToString(), Session["ProjectName"].ToString(), Session["Bugsubject"].ToString());
                                //        SendEmail(Email, GetProjectTitle(model.ProjectId), model.BugSubject);
                                //    });
                                //    threadSendMails.IsBackground = true;

                                //    threadSendMails.Start();
                                //}
                                string updatefile = string.Empty;
                                foreach (HttpPostedFileBase file in PostedFiles)
                                {
                                    if (file != null)
                                    {
                                        Guid   g1             = Guid.NewGuid();
                                        string ext            = System.IO.Path.GetExtension(file.FileName);
                                        string fileName       = g1 + ext;
                                        var    ServerSavePath = Path.Combine(Server.MapPath("~/BugUploadDocument/") + fileName);
                                        file.SaveAs(ServerSavePath);
                                        updatefile = UpdateBugFiles(model.BugId, fileName);
                                    }
                                }
                                if (updatefile != null)
                                {
                                    if (updatefile == "UpdateImage")
                                    {
                                    }
                                }
                                ModelState.Clear();
                                ModelState.AddModelError("CustomError", Response.response);
                                ViewBag.Class = "alert-success";
                                model         = new BugsModel();
                            }
                        }
                    }
                    else if (result.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        var contents = result.Content.ReadAsStringAsync().Result;
                        var Response = Newtonsoft.Json.JsonConvert.DeserializeObject <ResponseModel>(contents);
                        ModelState.AddModelError("CustomError", Response.response);
                        ViewBag.Class = "alert-danger";
                    }
                    else
                    {
                        ModelState.AddModelError("CustomError", "Error occurred");
                        ViewBag.Class = "alert-danger";
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                ModelState.AddModelError("CustomError", ex.Message);
                ViewBag.Class = "alert-danger";
            }
            client             = new HttpClient();
            client.BaseAddress = new Uri(HttpContext.Request.Url.AbsoluteUri);
            var Clientresult = client.GetAsync(BaseURL + "/api/Bugs/GetEmployees").Result;

            if (Clientresult.StatusCode == HttpStatusCode.OK)
            {
                var contents = Clientresult.Content.ReadAsStringAsync().Result;
                var response = new JavaScriptSerializer().Deserialize <List <EmployeesDomainModel> >(contents);
                model.listEmployees = response;
            }
            var ClientResult1 = client.GetAsync(BaseURL + "/api/Project/GetProjectList").Result;

            if (ClientResult1.StatusCode == HttpStatusCode.OK)
            {
                var contents = ClientResult1.Content.ReadAsStringAsync().Result;
                var response = new JavaScriptSerializer().Deserialize <List <ProjectDomainModel> >(contents);
                model.listProjects = response;
            }
            var listPriority = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "High", Value = "High"
                },
                new SelectListItem {
                    Text = "Low", Value = "Low"
                },
                new SelectListItem {
                    Text = "Urgent", Value = "Urgent"
                },
                new SelectListItem {
                    Text = "Immediate", Value = "Immediate"
                }
            };
            var listStatus = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "New", Value = "New"
                },
                new SelectListItem {
                    Text = "ReOpened", Value = "ReOpened"
                },
                new SelectListItem {
                    Text = "Closed", Value = "Closed"
                }
            };

            ViewData["ddlPriority"] = listPriority;
            ViewData["ddlStatus"]   = listStatus;
            return(View(model));
        }
Example #14
0
 public void Post(BugsModel value)
 {
     bug.Add(value);
 }
Example #15
0
        public HttpStatusCode EditBug(BugsModel bug)
        {
            var result = _bugsGateway.EditBug(bug);

            return(result.Result);
        }
Example #16
0
 public ActionResult EditBug(BugsModel bug)
 {
     _BugsService.EditBug(bug);
     return(View());
 }
Example #17
0
 public ActionResult CreateBug(BugsModel model)
 {
     model.TimeStamp = DateTime.Now;
     _BugsService.CreateBug(model);
     return(RedirectToAction("Index"));
 }
 public async Task <HttpStatusCode> EditBug(BugsModel bug)
 {
     throw new NotImplementedException();
 }