Esempio n. 1
0
        public IActionResult Post([FromBody] Models.Activity activity)
        {
            var result = _activityRepository.CreateActivity(activity);

            if (result > 0)
            {
                return(StatusCode(201, result));
            }
            else
            {
                return(StatusCode(500));
            }
        }
Esempio n. 2
0
        public IActionResult Create([FromBody] ActivityRequest request)
        {
            var activity = Mapper.Map <Activity>(request);

            activityRepository.CreateActivity(activity);

            var response = Mapper.Map <ActivityResponse>(activity);

            return(Ok(response));
        }
        public ActionResult <Activity> createActivity(int userId, Activity activity)
        {
            var user = _repoWrapper.User.FindById(userId);

            if (user == null)
            {
                return(Ok(user));
            }
            activity.User = user;
            _activityRepo.CreateActivity(activity);
            _repoWrapper.Save();

            return(Ok(activity));
        }
        public ActionResult CreateActivity(EditActivityViewModel model)
        {
            //ActivityType type = activityTypeRepository.ActivityTypes.FirstOrDefault(x => x.ToString() );
            //activity.ActivityTypeCurrent = type;

            if (ModelState.IsValid)
            {
                model.Activity.ActivityTypeCurrent = activityTypeRepository.ActivityTypes
                                                     .FirstOrDefault(p => p.ActivityTypeId.ToString() == model.CurrentCategory);

                activityRepository.CreateActivity(model.Activity, CurrentUser);
                TempData["message"] = string.Format("Изменения в мероприятии \"{0}\" были сохранены", model.Activity.ActivityName);
                return(RedirectToAction("List", "Activity", null));
            }
            else
            {
                // Что-то не так со значениями данных
                TempData["error"] = string.Format("Ошибка при создании мероприятия \"{0}\"! ", model.Activity.ActivityName);
            }
            return(RedirectToAction("List", "Activity", null));
        }
Esempio n. 5
0
 public async Task CreateActivity([FromBody] Activity body)
 {
     _repository.CreateActivity(body);
 }
 public async Task CreateActivity([FromBody] CreateActivity command)
 {
     await _activityRepository.CreateActivity(command.UserEmail, command.ActivityName, command.Distance, command.TimeInSec);
 }
Esempio n. 7
0
 public void AddActivity(Activity activity)
 {
     _activityRepository.CreateActivity(activity);
 }