public ActionResult _BugsList(long UserId = 0, long ProjectId = 0) { BugsDomainModel model = new BugsDomainModel(); List <BugsDomainModel> listBugs = new List <BugsDomainModel>(); if (UserManager.user.roleType == roleTypeModel.Admin || UserManager.user.roleType == roleTypeModel.HR || UserManager.user.roleType == roleTypeModel.ProjectManager) { model.BugId = 0; model.Mode = "QA"; model.UserId = UserId; model.ProjectId = ProjectId; } else { model.BugId = 0; model.Mode = "Employee"; model.UserId = UserManager.user.UserId; model.ProjectId = ProjectId; } var client = new HttpClient(); 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 <BugsDomainModel> >(contents); listBugs = Response; } return(PartialView(listBugs)); }
public HttpResponseMessage AddAddUpdateBug(BugsDomainModel model) { HttpResponseMessage httpResponse = new HttpResponseMessage(); try { var response = bugRepository.AddUpdateBug(model); if (response == null) { httpResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, "Error Occurred"); } else { httpResponse = Request.CreateResponse(HttpStatusCode.OK, response); } return(httpResponse); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "An error occurred, please try again or contact the administrator.", StatusCode = HttpStatusCode.InternalServerError }); } }
public ResponseDomainModel AddUpdateBug(BugsDomainModel model) { ResponseDomainModel objRes = new ResponseDomainModel(); try { var res = objHelper.Query <string>("AddUpdateBug", new { bugid = model.BugId, userid = model.UserId, bugreportedby = model.BugReportedBy, projectid = model.ProjectId, subject = model.BugSubject, description = model.BugDescription, file = model.Files, priority = model.Priority, status = model.Status }).FirstOrDefault(); if (string.IsNullOrWhiteSpace(res)) { objRes.isSuccess = false; objRes.response = "Something went wrong, please try again."; } else if (res == "Insert") { objRes.isSuccess = true; objRes.response = "Bug added successfully."; } else if (res == "Update") { objRes.isSuccess = true; objRes.response = "Bug updated successfully."; } else if (res == "Change") { objRes.isSuccess = false; objRes.response = "Not a valid Request."; } else { objRes.isSuccess = false; objRes.response = "Something went wrong, please try again."; } } catch (Exception ex) { ErrorLog.LogError(ex); objRes.isSuccess = false; objRes.response = ex.Message; } return(objRes); }
public List <BugsDomainModel> GetBugDetails(BugsDomainModel model) { try { var listBugs = objHelper.Query <BugsDomainModel>("GetBugDetails_New", new { bugid = model.BugId, mode = model.Mode, userid = model.UserId, projectid = model.ProjectId }).ToList(); return(listBugs); } catch (Exception ex) { ErrorLog.LogError(ex); return(null); } }