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); } }
public PartialViewResult Edit(TrainerBasic trainer) { trainerManager.EditTrainer(trainer); List <TrainerBasic> trainers = trainerManager.GetAllTrainers(); return(PartialView("_TrainersPartial", trainers)); }
public ActionResult GetTrainer(int trainerId) { TrainerBasic trainer = trainerManager.GetTrainer(trainerId); if (trainer != null) { return(Ok(trainer)); } else { return(BadRequest()); } }
public ActionResult AddTrainer([FromBody] TrainerBasic trainerBasic) { int res = -1; res = trainerManager.AddTrainer(trainerBasic); if (res != -1) { return(Ok(res)); } else { return(BadRequest()); } }
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); } }
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)); }
public int EditTrainer(TrainerBasic trainerBasic) { throw new NotImplementedException(); }
public JsonResult Create(TrainerBasic trainer) { int trainerId = trainerManager.AddTrainer(trainer); return(Json(trainerId)); }