/// <summary> /// Change Activity informations. /// </summary> /// <param name="request">activity request.</param> /// <returns>Activity message.</returns> public ActivityMessage UpdateActivity(ActivityRequest request) { ActivityMessage message = new ActivityMessage(); try { request.FindActivityDto = FindActivityDto.ActivityId; ActivityResponsePivot response = _serviceActivity.FindActivities(request.ToPivot()); if (response?.ActivityPivot != null) { _serviceActivity.UpdateActivity(request.ToPivot()); message.OperationSuccess = true; } else { message.ErrorMessage = ActivityMessageResource.NotFoundActivity; message.ErrorType = ErrorType.FunctionalError; message.OperationSuccess = false; } } catch (Exception e) { message.ErrorType = ErrorType.TechnicalError; message.ErrorMessage = e.Message; } return(message); }
public IActionResult Update([FromBody] ActivityViewModel activityViewModel, int id) { try { Activity activity = serviceActivity.GetActivityById(id); activity.Description = activityViewModel.Description; activity.BeginTimeActivity = activityViewModel.BeginningTime; activity.EndTimeActivity = activityViewModel.EndingTime; serviceActivity.UpdateActivity(activity); return(Ok(ToOutputModel(activity))); } catch { return(BadRequest()); } }