public IActionResult UpdateMashReferral([FromBody] UpdateMashReferral request, long referralId) { var validator = new UpdateMashReferralValidator(); var validation = validator.Validate(request); if (!validation.IsValid) { return(BadRequest(validation.ToString())); } try { var updatedReferral = _mashReferralUseCase.UpdateMashReferral(request, referralId); return(Ok(updatedReferral)); } catch (Exception e) when( e is MashReferralNotFoundException || e is WorkerNotFoundException || e is MashReferralStageMismatchException) { return(BadRequest(e.Message)); } }
public void WhenUpdateTypeIsContactDecisionRequiresUrgentContactMustBeProvided() { var request = TestHelpers.CreateUpdateMashReferral(updateType: "CONTACT-DECISION"); request.WorkerId = null; request.RequiresUrgentContact = null; var validationResult = _validator.Validate(request); validationResult.ToString().Should().Be("Must provide if urgent contact is required"); }