public async Task <bool> UpdateMicrocycle(MicrocycleDto microcycleDto) { var newRec = Mapper.Map <Microcycle>(microcycleDto); //Update the database return(await _db.UpdateAsync(newRec)); }
public async Task <int> CreateMicrocycle(MicrocycleDto microcycleDto) { //Map to the Data Entity object var recDb = Mapper.Map <Microcycle>(microcycleDto); //Insert into Message table await _db.InsertAsync(recDb); return(recDb.Id); }
public async void CreateMicrocycle() { var microcycle = new MicrocycleDto() { EndDate = DateTime.Now, Name = "TestMicroCycle", SeasonId = 1, StartDate = DateTime.Now, SubTeamId = 2, TeamId = 1 }; var result = await _service.CreateMicrocycle(microcycle); Assert.NotEqual(0, result); }
public async void UpdateMicrocycle() { var microcycle = new MicrocycleDto() { EndDate = DateTime.Now, Name = "TestMicroCycleUPDATED", SeasonId = 1, StartDate = DateTime.Now, SubTeamId = 2, TeamId = 1, Id = 2 }; var result = await _service.UpdateMicrocycle(microcycle); Assert.Equal(true, result); }
public async Task <IActionResult> CreateMicrocycle([FromBody, Required] MicrocycleDto microcycleDTO) { try { if (microcycleDTO == null) { return(BadRequest()); } var result = await _service.CreateMicrocycle(microcycleDTO); return(CreatedAtRoute("default", result)); } catch (Exception ex) { Log.Error(ex, ex.Message); return(BadRequest(ex.Message)); } }
public async Task <IActionResult> UpdateSubPosition([FromBody, Required] MicrocycleDto microcycleDto) { try { if (microcycleDto == null) { return(BadRequest()); } if (await _service.UpdateMicrocycle(microcycleDto)) { return(CreatedAtRoute("default", true)); } return(BadRequest("Failed to update the database")); } catch (Exception ex) { Log.Error(ex, ex.Message); return(BadRequest(ex.Message)); } }