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 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 IActionResult Delete(int id) { try { _service.Delete(id); return(Ok()); } catch (Exception e) { _logger.LogWarning($"Delete method with parameters ({id});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult Patch(int id, [FromBody] MemberPreferencesView memberPreferencesView) { memberPreferencesView.Id = id; try { return(Ok(_service.PatchPreferences(memberPreferencesView))); } catch (Exception e) { _logger.LogWarning($"Patch method with parameters ({id}, {memberPreferencesView});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult Patch(int id, [FromBody] MemberNotificationView memberNotificationView) { memberNotificationView.Id = id; try { return(Ok(_service.PatchNotifications(this.GetUserNameWithImpersonation(), memberNotificationView))); } catch (Exception e) { _logger.LogWarning($"Patch method with parameters ({id}, {memberNotificationView});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult Update(int id, [FromBody] TimeEntryView timeEntryView) { timeEntryView.Id = id; try { return(new JsonResult(_service.Update(timeEntryView))); } catch (Exception e) { _logger.LogWarning($"Update method with parameters ({id}, {timeEntryView});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }
public IActionResult Patch(int id, [FromBody] TimeEntryTime timeEntryTime) { timeEntryTime.Id = id; try { return(Ok(_service.Patch(timeEntryTime, this.GetUserNameWithImpersonation()))); } catch (Exception e) { _logger.LogWarning($"Patch method with parameters ({id}, {timeEntryTime});\n {e}"); var errors = ExceptionsChecker.CheckTimeEntriesException(e); return(BadRequest(errors)); } }