public async Task <IHttpActionResult> PutActivity(int id, ActivityDto activity) { var activityFromRepo = await _Repo.GetActivities(id); if (activityFromRepo != null) { if (activityFromRepo.Active == activity.Active) { if (activityFromRepo.ActivityName != activity.ActivityName && await _Repo.ActivityExists(activity.ActivityName)) { return(BadRequest("Kegiatan sudah pernah dibuat")); } } } else { return(BadRequest("Data tidak ditemukan")); } await _Repo.UpdateActivity(activity); return(StatusCode(HttpStatusCode.NoContent)); }
private bool ActivitiesExists(int id) { return(_activitiesRepository.ActivityExists(id)); }