public void ShouldAddFavoriteProduct() { var usf = crudOnFavorites.AddProductToFavorites(username, productId).Result; Assert.AreEqual(usf.Username, username); Assert.AreEqual(usf.ProductId, productId); crudOnFavorites.DeleteProductFromFavorites(username, productId); }
public async Task <IHttpActionResult> Post(string username, int productId) { if (!await authorization.UserIsHimself(User.Identity.GetUserName(), username)) { return(Unauthorized()); } try { var usf = await crudOnFavorites.AddProductToFavorites(username, productId); var viewUsf = Mapper.Map <ViewUsersFavoriteProducts>(usf); return(Ok(viewUsf)); } catch (Exception ex) { return(throwExceptionToUser.Throw(ex)); } }