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()); }
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)); }
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)); }
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; } }
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)); }
public async Task <ActionResult> AddActivity(Activity activity) { return(Ok(await _activityRepository.AddActivity(activity))); }
public async Task <ActionResult> Post(string iso, Activity activity) { await _activityRepository.AddActivity(activity, iso); return(NoContent()); }
public async Task AddActivity(Activity activity, int userid) { await _activityRepository.AddActivity(activity, userid); }