public IActionResult PostReportsGrid([FromBody] RequestReportsGrid reportsGridData) { try { var userName = this.GetUserNameWithImpersonation(); // 0 - Default(none), 1 - Projects, 2 - Users, 3 - Dates, 4 - Clients. switch (reportsGridData.GroupById) { case (int)ReportsGroupBy.Project: return(new JsonResult(_service.GroupByProjects(userName, reportsGridData))); case (int)ReportsGroupBy.User: return(new JsonResult(_service.GroupByUsers(userName, reportsGridData))); case (int)ReportsGroupBy.Date: return(new JsonResult(_service.GroupByDates(userName, reportsGridData))); case (int)ReportsGroupBy.Client: return(new JsonResult(_service.GroupByClients(userName, reportsGridData))); default: return(new JsonResult(_service.GroupByNone(userName, reportsGridData))); } } catch (Exception e) { _logger.LogWarning($"PostReportsGrid method with parameters ({reportsGridData});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult Create([FromBody] TaskView taskTypeData) { if (!ModelState.IsValid) { return(BadRequest(new List <ErrorView> { new ErrorView { Source = "Other", Title = "", Details = "ModelState is invalid." } })); } try { var result = _service.Create(taskTypeData, this.GetUserName()); var locationUri = $"{Request.Host}/api/v1/odata/Tasks({result.Id})"; return(Created(locationUri, _mapper.Map <TaskType, TaskView>(result))); } catch (Exception e) { _logger.LogWarning($"Create method with parameters ({JsonConvert.SerializeObject(taskTypeData)});\n {e}"); var errors = ExceptionsChecker.CheckTasksException(e); return(BadRequest(errors)); } }
public IActionResult Update(int id, [FromBody] dynamic taskTypeData) { if (!ModelState.IsValid) { return(BadRequest(new List <ErrorView> { new ErrorView { Source = "Other", Title = "", Details = "ModelState is invalid." } })); } taskTypeData.Id = id; try { var result = _service.Update(taskTypeData, this.GetUserName()); return(new ObjectResult(_mapper.Map <TaskType, TaskView>(result))); } catch (Exception e) { _logger.LogWarning($"Update methodwith parameters ({id}, {taskTypeData});\n {e}"); var errors = ExceptionsChecker.CheckTasksException(e); return(BadRequest(errors)); } }
protected IActionResult SendErrorResponse(Exception e) { _logger.LogError($"Path: {(Request.Path)} , Query: {Request.QueryString}", e); var error = ExceptionsChecker.CheckProjectRolesException(e); return(BadRequest(error)); }
public IActionResult Get() { try { // Get qry parameters (range dates for timeentries) from request string get. var queryStringOdata = HttpContext.Request.QueryString.Value; var regex = new Regex(@"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}"); var dates = new List <DateTime>(); if (regex.Match(queryStringOdata).Success) { foreach (var match in regex.Matches(queryStringOdata)) { //DateTime dt = DateTime.ParseExact(m.Value, "yyyy-MM-ddThh:mm:ssZ", CultureInfo.InvariantCulture); var dt = Convert.ToDateTime(match.ToString()); dates.Add(dt); } } var dateStart = dates.Min(x => x); var dateEnd = dates.Max(x => x); return(Ok(_service.GetAllTimeEntries(this.GetUserNameWithImpersonation(), dateStart, dateEnd))); } catch (Exception e) { _logger.LogError($"Get method {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public async Task <IActionResult> SentReport([FromBody] ReportsSendAsEmailView reportsGridData) { try { var userName = this.GetUserNameWithImpersonation(); switch (reportsGridData.GroupById) { case (int)ReportsGroupBy.Project: { await _service.SentGroupByProjects(userName, reportsGridData); break; } case (int)ReportsGroupBy.User: { await _service.SentGroupByUsers(userName, reportsGridData); break; } case (int)ReportsGroupBy.Date: { await _service.SentGroupByDates(userName, reportsGridData); break; } case (int)ReportsGroupBy.Client: { await _service.SentGroupByClients(userName, reportsGridData); break; } default: { await _service.SentGroupByNone(userName, reportsGridData); break; } } return(Ok()); } catch (Exception e) { _logger.LogWarning($"PostReportsGrid method with parameters ({reportsGridData});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult Get() { try { return(Ok(_service.TimeTrackerAllProjects(this.GetUserNameWithImpersonation()))); } catch (Exception e) { _logger.LogWarning($"Get method {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult GetNotAssignMembersAtProjByMemberId(int memberId) { try { return(Ok(_service.GetNotAssignMembersAtProjByMemberId(memberId))); } catch (Exception e) { _logger.LogWarning($"GetNotAssignMembersByMemberId method with parameter ({memberId});\n {e}"); var errors = ExceptionsChecker.CheckProjectRolesException(e); return(BadRequest(errors)); } }
public IActionResult GetById(int id) { try { return(new ObjectResult(_service.GetById(id))); } catch (Exception e) { _logger.LogWarning($"GetById method with parameter ({id});\n {e}"); var errors = ExceptionsChecker.CheckProjectRolesException(e); return(BadRequest(errors)); } }
public IActionResult GetPicturesCacheGuid() { try { return(new JsonResult(_service.GetPicturesCacheGuid())); } catch (Exception e) { _logger.LogWarning($"GetPicturesCacheGuid method {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public ActionResult GetMembers(int id) { try { return(Ok(_service.GetMembers(id))); } catch (Exception e) { _logger.LogWarning($"GetMembers method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult Create([FromBody] TimeEntryView timeEntryView) { try { return(new JsonResult(_service.Create(timeEntryView, this.GetUserNameWithImpersonation()))); } catch (Exception e) { _logger.LogWarning($"Create method with parameters ({timeEntryView});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult GetById(int id) { try { return(new JsonResult(_service.GetById(id, this.GetUserNameWithImpersonation()))); } catch (Exception e) { _logger.LogWarning($"GetById method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult Get(DateTimeOffset dateBegin, DateTimeOffset dateEnd) { try { return(new JsonResult(_service.GetAllTimeEntries(this.GetUserNameWithImpersonation(), dateBegin, dateEnd))); } catch (Exception e) { _logger.LogError($"Get method {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public ActionResult ManageProjectsOfManager() { try { return(Ok(_service.ManageProjectsOfManager(this.GetUserNameWithImpersonation()))); } catch (Exception e) { _logger.LogWarning($"ProjectsByManager method {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult Get() { try { return(Ok(_service.GetAllClients())); } catch (Exception e) { _logger.LogWarning($"Get method;\n {e}"); var errors = ExceptionsChecker.CheckClientsException(e); return(BadRequest(errors)); } }
public ActionResult GetMemberProjects() { try { return(new JsonResult(_service.GetMemberProjects())); } catch (Exception e) { _logger.LogWarning($"GetMemberProjects method {e}"); var errors = ExceptionsChecker.CheckProfileException(e); return(BadRequest(errors)); } }
public IActionResult GetDropdowns() { try { return(new JsonResult(_service.ReportsDropDowns())); } catch (Exception e) { _logger.LogError($"GetReportsDropdowns method {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public ActionResult UpdateManagerRoles() { try { var result = _roleService.FixAllManagerRoles(); return(Ok(result)); } catch (Exception e) { _logger.LogWarning($"UpdateManagerRoles method {e}"); var errors = ExceptionsChecker.CheckProjectRolesException(e); return(BadRequest(errors)); } }
public IActionResult GetMemberAvatar(int memberId) { try { var result = _avatarService.GetAvatar(memberId); return(Ok(result)); } catch (Exception e) { _logger.LogWarning($"GetMemberAvatar method with parameters ({memberId});\n {e}"); var errors = ExceptionsChecker.CheckProfileException(e); return(BadRequest(errors)); } }
public ActionResult GetProjectMembers(int projectId) { try { var result = _service.GetProjectMembers(projectId); return(Ok(result)); } catch (Exception e) { _logger.LogWarning($"GetProjectMembers method with parameters ({projectId});\n {e}"); var errors = ExceptionsChecker.CheckProfileException(e); return(BadRequest(errors)); } }
public IActionResult GetDateFormats() { try { var result = _service.GetDateFormats(); return(new JsonResult(result)); } catch (Exception e) { _logger.LogWarning($"GetDateFormats method {e}"); var errors = ExceptionsChecker.CheckProfileException(e); return(BadRequest(errors)); } }
public IActionResult GetMemberIcon(int memberId) { try { var result = _service.GetMemberIcon(this.GetUserNameWithImpersonation(), memberId); return(Ok(result)); } catch (Exception e) { _logger.LogWarning($"GetMemberIcon method with parameters ({memberId});\n {e}"); var errors = ExceptionsChecker.CheckProfileException(e); return(BadRequest(errors)); } }
public ActionResult UpdateClaims() { try { _service.UpdateUsersClaims(); return(Ok(true)); } catch (Exception e) { _logger.LogWarning($"UpdateClaims method {e}"); var errors = ExceptionsChecker.CheckMembersException(e); return(BadRequest(errors)); } }
public IActionResult Delete(int id) { try { var result = _service.Delete(id); return(Ok()); } catch (Exception e) { _logger.LogWarning($"Delete method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckTasksException(e); return(BadRequest(errors)); } }
public IActionResult GetById(int id) { try { var value = _service.GetById(id); return(new ObjectResult(_mapper.Map <TaskType, TaskView>(value))); } catch (Exception e) { _logger.LogWarning($"GetById method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckTasksException(e); return(BadRequest(errors)); } }
public IActionResult Delete(int id) { try { var result = _service.Delete(id, this.GetUserNameWithImpersonation()); return(Ok()); } catch (Exception e) { _logger.LogWarning($"Delete method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult GetById(int id) { try { var result = _service.GetById(id, this.GetUserNameWithImpersonation()); return(new ObjectResult(result)); } catch (Exception e) { _logger.LogWarning($"GetById with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult GetGridAndSaveCurrentQuery([FromBody] ReportsGridView reportsGridView) { if (!ModelState.IsValid) { return(BadRequest("Invalid Model")); } try { var userName = this.GetUserNameWithImpersonation(); _reportsSettingsService.SaveCurrentQuery(reportsGridView.CurrentQuery, userName); // 0 - Default(none), 1 - Projects, 2 - Users, 3 - Dates, 4 - Clients. switch (reportsGridView.CurrentQuery.GroupById) { case (int)Constants.ReportsGroupBy.Project: { return(new JsonResult(_service.ReportsGridGroupByProjects(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.User: { return(new JsonResult(_service.ReportsGridGroupByUsers(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.Date: { return(new JsonResult(_service.ReportsGridGroupByDates(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.Client: { return(new JsonResult(_service.ReportsGridGroupByClients(userName, reportsGridView))); } default: { return(BadRequest("Invalid Grouping value")); } } } catch (Exception e) { _logger.LogWarning($"PostReportsGrid method with parameters ({reportsGridView});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public async Task <IActionResult> ReportsExportEmail([FromBody] ReportsExportEmailView reportsGridData) { try { switch (reportsGridData.CurrentQuery.GroupById) { case (int)ReportsGroupBy.Project: { await _service.ExportEmailGroupByProjects(reportsGridData); break; } case (int)ReportsGroupBy.User: { await _service.ExportEmailGroupByUsers(reportsGridData); break; } case (int)ReportsGroupBy.Date: { await _service.ExportEmailGroupByDates(reportsGridData); break; } case (int)ReportsGroupBy.Client: { await _service.ExportEmailGroupByClients(reportsGridData); break; } default: { return(BadRequest()); } } return(Ok()); } catch (Exception e) { _logger.LogWarning($"ReportsExportEmail method with parameters ({reportsGridData});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }