|
|
@ -5,7 +5,7 @@ using System.Collections.Immutable;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LocalServices
|
|
|
|
namespace LocalServices
|
|
|
|
{
|
|
|
|
{
|
|
|
|
internal class AccountRecipesPreferences : IAccountRecipesPreferencesService
|
|
|
|
public class AccountRecipesPreferences : IAccountRecipesPreferencesService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IDatabase db;
|
|
|
|
private readonly IDatabase db;
|
|
|
@ -56,7 +56,7 @@ namespace LocalServices
|
|
|
|
|
|
|
|
|
|
|
|
public RecipeRate GetRate(RecipeInfo info)
|
|
|
|
public RecipeRate GetRate(RecipeInfo info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RecipeRate rate = null;
|
|
|
|
RecipeRate? rate = null;
|
|
|
|
var ratings = db.ListRatesOf(Account.User.Id);
|
|
|
|
var ratings = db.ListRatesOf(Account.User.Id);
|
|
|
|
|
|
|
|
|
|
|
|
if (!ratings.TryGetValue(info.Id, out rate))
|
|
|
|
if (!ratings.TryGetValue(info.Id, out rate))
|
|
|
@ -82,7 +82,6 @@ namespace LocalServices
|
|
|
|
public void AddToFavorites(RecipeInfo info)
|
|
|
|
public void AddToFavorites(RecipeInfo info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
var ratings = db.ListRatesOf(userId);
|
|
|
|
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
|
|
|
|
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(true, rate.Rate));
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(true, rate.Rate));
|
|
|
@ -91,7 +90,6 @@ namespace LocalServices
|
|
|
|
public void RemoveFromFavorites(RecipeInfo info)
|
|
|
|
public void RemoveFromFavorites(RecipeInfo info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
var ratings = db.ListRatesOf(userId);
|
|
|
|
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
|
|
|
|
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(false, rate.Rate));
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(false, rate.Rate));
|
|
|
@ -100,7 +98,6 @@ namespace LocalServices
|
|
|
|
public void SetReviewScore(RecipeInfo info, uint score)
|
|
|
|
public void SetReviewScore(RecipeInfo info, uint score)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
Guid userId = Account.User.Id;
|
|
|
|
var ratings = db.ListRatesOf(userId);
|
|
|
|
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
RecipeRate rate = GetRate(info);
|
|
|
|
|
|
|
|
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(rate.IsFavorite, Math.Min(score, 5)));
|
|
|
|
db.InsertRate(userId, info.Id, new RecipeRate(rate.IsFavorite, Math.Min(score, 5)));
|
|
|
|