/// <summary> /// Removes recommendation /// </summary> /// <param name="rec">Recommendation to remove</param> private void RemoveRecomendations(RecModel rec) { RecList.Remove(rec); // Since the recommendation was currently selected, we have to change it with another one if (rec == SelectedRec) { // If it was the last item, selects a new last item if (SelectedIndex >= RecList.Count) { SelectedIndex = RecList.Count - 1; if (SelectedIndex >= 0) { SelectedRec = RecList[SelectedIndex]; } } // If no more recommendations are left, removes selection if (RecList.Count == 0) { SelectedRec = null; } else { SelectedRec = RecList[SelectedIndex]; } } if (RecList.Count == 0) { Messenger.Default.Send("", MessengerToken.GetMoreRecs); RecsView.Close(); } }
/// <summary> /// Moves recommendation to "Pending recommendations" directory /// </summary> /// <param name="rec"></param> private static bool MoveRec(RecModel rec, string dir) { if (IsDirInAppData(WorkingDir)) { var fromDir = WorkingDir + DIR_RECS + rec; var toDir = WorkingDir + dir + rec; try { if (Directory.Exists(toDir)) { Directory.Delete(fromDir, true); } else { Directory.Move(fromDir, toDir); } return(true); } catch (UnauthorizedAccessException e) { MessageBox.Show("Error: " + e.ToString()); } catch (IOException e) { MessageBox.Show("Error: " + e.ToString()); } } return(false); }
public async Task SendDraw(RecModel model) { if (model.type == "clearBoard") { await _drawService.ClearModels(); } else { await _drawService.AddToModels(model); } await Clients.AllExcept(Context.ConnectionId).SendAsync("ReceiveDraw", model); }
/// <summary> /// Serializes a given match in it's own folder /// </summary> /// <param name="rec"></param> public static void SerializeRecommendation(RecModel rec) { string workingDir = WorkingDir + DIR_RECS + rec.ToString() + "\\"; // Rec doesn't have his own data folder if (!Directory.Exists(workingDir)) { CreateMatchFolder(workingDir); } DownloadPhotos(rec.Photos, workingDir); DownloadInstagramPhotos(rec.Instagram, workingDir); File.WriteAllText(workingDir + rec.Name.Unidecode() + EXT, JsonConvert.SerializeObject(rec, Formatting.Indented)); }
public async Task AddToModels(RecModel model) { await Task.Run(() => recModels.Add(model)); }
/// <summary> /// Moves photos of recommendation from "Pending recommendations" to "Matches" directory /// </summary> /// <param name="rec"></param> public static bool MoveRecFromPendingToMatches(RecModel rec) { return(MoveRecPhotosToMatches(rec.ToString(), DIR_RECS_PENDING)); }
public static bool MoveRecToMatches(RecModel rec) { return(MoveRecPhotosToMatches(rec.ToString(), DIR_RECS)); }
public static bool MoveRecToPending(RecModel rec) { return(MoveRec(rec, DIR_RECS_PENDING)); }
public static bool MoveRecToPassed(RecModel rec) { return(MoveRec(rec, DIR_RECS_PASSED)); }