public async Task DeleteMainObjective(long mainObjectiveId)
        {
            var mainObjective = new MainObjective();

            mainObjective.Id = mainObjectiveId;
            await _mainObjectiveRepository.Remove(mainObjective);
        }
Exemplo n.º 2
0
        public IHttpActionResult UpdateMainObjective(UpdateMainObjectiveVM mainObjective)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                MainObjective updateMainObjective = _mainObjectiveService.Find(c => c.Id == mainObjective.Id);
                if (updateMainObjective != null)
                {
                    updateMainObjective.Order      = mainObjective.Order;
                    updateMainObjective.Content    = mainObjective.Name;
                    updateMainObjective.CourseCode = mainObjective.CourseCode;

                    if (_mainObjectiveService.Update(updateMainObjective))
                    {
                        return(Ok());
                    }
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                _loggingService.Write(ex);
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 3
0
 public MainObjectiveVM ConvertMainObjective(MainObjective mainObjective)
 => Map(mainObjective, x => new MainObjectiveVM
 {
     Id         = x.Id,
     Order      = x.Order,
     Name       = x.Content,
     CourseCode = x.CourseCode
 });
        public async Task <MainObjectiveView> AddMainObjective(MainObjectiveView mainObjectiveView, long categoryId)
        {
            var mainObjective = new MainObjective();

            mainObjective            = Mapper.Map <MainObjectiveView, MainObjective>(mainObjectiveView);
            mainObjective.CategoryId = categoryId;

            var newMainObjective = await _mainObjectiveRepository.Add(mainObjective);

            var newMainObjectiveView = new MainObjectiveView();

            newMainObjectiveView = Mapper.Map <MainObjective, MainObjectiveView>(newMainObjective);

            return(newMainObjectiveView);
        }