public async Task <IHttpActionResult> PostAlert([FromBody] ViewAlert viewAlert) { try { var username = await crudOnUsers.GetUsernameById(viewAlert.UserId); if (!await authorization.UserIsHimself(User.Identity.GetUserName(), username)) { return(Unauthorized()); } var alert = Mapper.Map <Alert>(viewAlert); var newAlert = await crudOnAlerts.AddAlert(alert); var newViewAlert = Mapper.Map <ViewAlert>(newAlert); return(Ok(newViewAlert)); } catch (Exception ex) { return(throwExceptionToUser.Throw(ex)); } }
public void ShouldAddAlert() { var newAlert = crudOnAlerts.AddAlert(alert).Result; Assert.NotNull(newAlert); }