コード例 #1
0
        public async Task <bool> UpdateMicrocycle(MicrocycleDto microcycleDto)
        {
            var newRec = Mapper.Map <Microcycle>(microcycleDto);

            //Update the database
            return(await _db.UpdateAsync(newRec));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: SettingsTests.cs プロジェクト: xtophs/SPP_Public
        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);
        }
コード例 #4
0
ファイル: SettingsTests.cs プロジェクト: xtophs/SPP_Public
        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);
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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));
            }
        }