public async Task <IActionResult> Create([FromBody] CreateReviewAndNotitficationDto reviewAndNotificationDto) { if (reviewAndNotificationDto == null) { return(NotFound()); } if (ModelState.IsValid) { var reviewCreateMapped = new CreateReviewDto { Comment = reviewAndNotificationDto.review.Comment, CustomerId = reviewAndNotificationDto.review.CustomerId, TeamMemberId = reviewAndNotificationDto.review.TeamMemberId }; var reviewNotificationCreateMapped = new CreateReviewNotificationsDto { ReviewActionId = reviewAndNotificationDto.reviewNotification.ReviewActionId, ReviewKindId = reviewAndNotificationDto.reviewNotification.ReviewKindId, StartDate = reviewAndNotificationDto.reviewNotification.StartDate, EndDate = reviewAndNotificationDto.reviewNotification.EndDate, DateAdded = DateTime.UtcNow }; //var reviewMapped = Mapper.Map<CreateReviewDto>(reviewAndNotificationDto); //var notificationMapped = Mapper.Map<CreateReviewNotificationsDto>(reviewAndNotificationDto); // var targetReview = Mapper.Map<Reviews>(reviewMapped); var targetReview = Mapper.Map <Reviews>(reviewCreateMapped); await _review.Create(targetReview); // if (!await _review.Save()) { return(StatusCode(500, "Server Error, Something went wrong with our server")); } var createdReview = Mapper.Map <Reviews>(targetReview); //notificationMapped.ReviewId = createdReview.Id; reviewNotificationCreateMapped.ReviewId = createdReview.Id; // var targetNotification = Mapper.Map<ReviewNotifications>(notificationMapped); var targetNotification = Mapper.Map <ReviewNotifications>(reviewNotificationCreateMapped); await _reviewNotification.Create(targetNotification); if (!await _review.Save()) { return(StatusCode(500, "Server Error, Something went wrong with our server")); } var createdNotification = Mapper.Map <ReviewNotifications>(targetNotification); return(CreatedAtRoute("GetReview", new { id = createdNotification.Id }, createdNotification)); //return CreatedA("/GetReview/"+ createdNotification.Id, createdNotification); } else { return(BadRequest(ModelState)); } }