예제 #1
0
        public int EditTrainer(TrainerBasic trainerBasic)
        {
            try
            {
                Trainer trainer = unitOfWork.TrainerRepository.GetByID(trainerBasic.Id);
                if (trainer != null)
                {
                    trainer.Description = trainerBasic.Description;
                    trainer.FullName    = trainerBasic.FullName;
                    trainer.Photo       = trainerBasic.Photo;
                    trainer.Title       = trainerBasic.Title;

                    unitOfWork.TrainerRepository.Update(trainer);
                    unitOfWork.Save();

                    return(trainer.Id);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
예제 #2
0
        public PartialViewResult Edit(TrainerBasic trainer)
        {
            trainerManager.EditTrainer(trainer);

            List <TrainerBasic> trainers = trainerManager.GetAllTrainers();

            return(PartialView("_TrainersPartial", trainers));
        }
예제 #3
0
        public ActionResult GetTrainer(int trainerId)
        {
            TrainerBasic trainer = trainerManager.GetTrainer(trainerId);

            if (trainer != null)
            {
                return(Ok(trainer));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #4
0
        public ActionResult AddTrainer([FromBody] TrainerBasic trainerBasic)
        {
            int res = -1;

            res = trainerManager.AddTrainer(trainerBasic);

            if (res != -1)
            {
                return(Ok(res));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #5
0
        public int AddTrainer(TrainerBasic trainerBasic)
        {
            try
            {
                Trainer trainer = new Trainer()
                {
                    Description = trainerBasic.Description,
                    FullName    = trainerBasic.FullName,
                    Photo       = trainerBasic.Photo,
                    Title       = trainerBasic.Title
                };

                unitOfWork.TrainerRepository.Insert(trainer);
                unitOfWork.Save();

                return(trainer.Id);
            }
            catch (Exception ex)
            {
                return(-1);
            }
        }
예제 #6
0
        public PartialViewResult GetFor(int trainerId, string htmlClass, string actionName, string controllerName)
        {
            TrainerBasic trainerBasic;

            if (trainerId != 0)
            {
                trainerBasic = trainerManager.GetTrainer(trainerId);
            }
            else
            {
                trainerBasic = new TrainerBasic();
            }

            TrainerViewModel trainer = new TrainerViewModel()
            {
                TrainerBasic   = trainerBasic,
                HtmlClass      = htmlClass,
                ActionName     = actionName,
                ControllerName = controllerName
            };

            return(PartialView("_TrainerPartial", trainer));
        }
예제 #7
0
 public int EditTrainer(TrainerBasic trainerBasic)
 {
     throw new NotImplementedException();
 }
예제 #8
0
        public JsonResult Create(TrainerBasic trainer)
        {
            int trainerId = trainerManager.AddTrainer(trainer);

            return(Json(trainerId));
        }