public IHttpActionResult CancelBooking(BookingCancelModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { Cad.CancelBooking(User.Identity.GetUserId(), model.BookingId); } catch (ConnectedApartmentsException e) { return(BadRequest(e.Message)); } catch (Exception) { return(InternalServerError()); } return(GetResponse()); }
public TenantCancelBookingTests() { facade = new Mock <IFacade>(); var username = "******"; var identity = new GenericIdentity(username, ""); var nameIdentityClaim = new Claim(ClaimTypes.NameIdentifier, username); identity.AddClaim(nameIdentityClaim); var principal = new Mock <IPrincipal>(); principal.Setup(p => p.Identity).Returns(identity); principal.Setup(p => p.IsInRole("Tenant")).Returns(true); model = new BookingCancelModel() { BookingId = 3 }; controllerContext = new HttpControllerContext { RequestContext = { Principal = principal.Object } }; }