Example #1
0
        public ProgramSchedule AddNewProgramSchedule(CreateProgramScheduleDto dto)
        {
            var type = new CreateProgramTypeDto
            {
                Name = dto.TypeName,
            };

            _programTypeService.AddNewProgramType(type);
            var program = new ProgramSchedule
            {
                ProgramTypeId               = _programTypeService.GetProgramByName(type.Name).Id,
                FitnessProgramName          = dto.FitnessProgramName,
                NutritionProgramName        = dto.NutritionProgramName,
                FitnessProgramDescription   = dto.FitnessProgramDescription,
                NutritionProgramDescription = dto.NutritionProgramDescription
            };

            _programScheduleRepository.Add(program);
            _programScheduleRepository.Save();
            _programTypeService.UpdateProgramTypeDetails(program.ProgramTypeId, new UpdateProgramTypeDto
            {
                ScheduleId = program.Id
            });
            return(program);
        }
Example #2
0
        public IActionResult Post([FromBody] CreateProgramScheduleDto dto)
        {
            var program = _programScheduleService.AddNewProgramSchedule(dto);

            if (program == null)
            {
                return(BadRequest("Program with such name already exists"));
            }

            var result = _mapper.Map <CreateProgramScheduleDto>(program);

            return(CreatedAtAction(nameof(Get), new { id = program.Id }, result));
        }