예제 #1
0
        public async Task <IActionResult> AddActivity([FromBody] AppActivity model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    logger.LogInformation("Adding Actiivty in Repository");
                    var addedActivity = await activityRepo.AddActivity(model);

                    if (addedActivity != null)
                    {
                        return(Ok(addedActivity));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception excp)
                {
                    logger.LogError("Error Adding Actiivty in Repository " + excp.Message);

                    return(BadRequest(excp));
                }
            }

            return(BadRequest());
        }
예제 #2
0
        public IActionResult CreateActivity([FromBody] ActivityCreateDto activityCreateDto)
        {
            var activitymodel = _mapper.Map <Activity>(activityCreateDto);

            _activityRepository.AddActivity(activitymodel);
            _activityRepository.Save();
            var activitytoReture = _mapper.Map <ActivitiesDto>(activitymodel);

            return(CreatedAtRoute("GetActivityById", new { activityId = activitytoReture.Id }, activitytoReture));
        }
예제 #3
0
        public IActionResult Post([FromBody] CreateActivityModel model)
        {
            var userId = this.GetAuthorizeUserId();

            var activityId = _activityRepository.AddActivity(userId, model.Name);

            var activity = new ActivityModel {
                Id = activityId, Name = model.Name
            };

            return(Created(string.Format("/api/users/{0}/activities/{1}", userId, activityId), activity));
        }
예제 #4
0
 public async Task Post([FromBody] Activity value)
 {
     try
     {
         await _activityRepository.AddActivity(value, int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value));
     }
     catch (Exception ex)
     {
         var h = ex;
         throw;
     }
 }
예제 #5
0
        public async Task <IActionResult> CreateActivity([FromBody] ActivityResource activityResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var activity = mapper.Map <ActivityResource, Activity>(activityResource);

            repository.AddActivity(activity);
            await unitOfWork.Complete();

            activity = await repository.GetActivity(activity.ActivityId);

            var result = mapper.Map <Activity, ActivityResource>(activity);

            return(Ok(result));
        }
예제 #6
0
 public async Task <ActionResult> AddActivity(Activity activity)
 {
     return(Ok(await _activityRepository.AddActivity(activity)));
 }
예제 #7
0
        public async Task <ActionResult> Post(string iso, Activity activity)
        {
            await _activityRepository.AddActivity(activity, iso);

            return(NoContent());
        }
예제 #8
0
 public async Task AddActivity(Activity activity, int userid)
 {
     await _activityRepository.AddActivity(activity, userid);
 }