public async Task <TimeRecordModel> CreateTimeRecord(TimeRecordModel timeRecordEntry) { var restRequest = _restClientFactory.CreateRequest("api/TimeRecord/CreateTimeRecord", Method.POST); restRequest.RequestFormat = DataFormat.Json; restRequest.AddJsonBody(timeRecordEntry); restRequest.AddHeader("authorization", string.Format("Bearer {0}", _apiToken)); var result = new TimeRecordModel(); var exceptions = new List <Exception>(); var remainingTries = 5; do { --remainingTries; try { var response = await _restClient.ExecuteAsync <TimeRecordModel>(restRequest); if (response.StatusCode == HttpStatusCode.OK) { result = response.Data; return(result); } } catch (Exception e) { exceptions.Add(e); } }while (remainingTries > 0); return(result); }
public async Task <IActionResult> Create(TimeRecordModel timeRecordEntry) { if (ModelState.IsValid) { var viewModel = await _timeRecordAPIClient.CreateTimeRecord(timeRecordEntry); return(RedirectToAction(nameof(Index))); } return(View(timeRecordEntry)); }
public async Task <ActionResult> DeleteTimeRecord(TimeRecordModel model) { try { var result = await TimeRecordServiceClient.DeleteTimerecord(model.Id); return(RedirectToAction("TimeRecordList")); } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
public async Task <ActionResult> EditTimeRecord(TimeRecordModel model) { try { var result = await TimeRecordServiceClient.EditTimeRecord(model.Id, model.Comment, model.TimeInSeconds, model.TodoId); return(RedirectToAction("TimeRecordList")); } catch (Exception e) { ViewBag.Message = e.Message; model.TodoList = await TodoServiceClient.GetAllTodo(); } return(View(model)); }
public async Task <ActionResult> AddTimeRecord() { var model = new TimeRecordModel(); try { model.TodoList = await TodoServiceClient.GetAllTodo(); } catch (Exception e) { ViewBag.Message = e.Message; model.TodoList = await TodoServiceClient.GetAllTodo(); } return(View(model)); }
public async Task <ActionResult> TimeRecordList() { var model = new TimeRecordModel(); try { var result = await TimeRecordServiceClient.GetAllTimeRecords(); model.TimeRecordList = await TimeRecordServiceClient.GetAllTimeRecords(); } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
public async Task <ActionResult> AddTimeRecord(TimeRecordModel model) { try { var result = await TimeRecordServiceClient.AddTimeRecord(model.Id, model.Comment, model.TimeInSeconds, model.TodoId); ViewBag.Message = "Sikeres mentés :)"; model.TodoList = await TodoServiceClient.GetAllTodo(); } catch (Exception e) { ViewBag.Message = e.Message; model.TodoList = await TodoServiceClient.GetAllTodo(); } return(View(model)); }
public async Task <ActionResult> DeleteTimeRecord(long id) { var model = new TimeRecordModel(); try { var result = await TimeRecordServiceClient.GeTimeRecordById(id); model.Id = result.Id; model.Comment = result.Comment; model.TimeInSeconds = result.TimeInSeconds; model.TodoTitle = result.TodoTitle; model.TodoId = result.TodoId; } catch (Exception e) { ViewBag.Message = e.Message; } return(View(model)); }
public async Task <IActionResult> Edit(int id, TimeRecordModel timeRecordEntry) { var viewModel = await _timeRecordAPIClient.UpdateTimeRecord(id, timeRecordEntry); return(RedirectToAction(nameof(Index))); }