private static void ShowAwardUsers() { Console.WriteLine("Enter award id"); string awardstring = Console.ReadLine(); int awardid; while (!int.TryParse(awardstring, out awardid)) { Console.WriteLine("Enter a valid integer"); awardstring = Console.ReadLine(); } try { var users = awardLogic.Users(awardid); var award = awardLogic.Get(awardid); if (users.Count > 0) { Console.WriteLine($"Award {award.Name} has been granted to these users:"); foreach (var user in users) { Console.WriteLine($"{user.Username}"); } } else { Console.WriteLine($"Award {award.Name} has not been granted to any user"); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public ActionResult Delete(int id) { try { var award = awardLogic.Get(id); var awardModel = new AwardModel(award.Title, award.Id); return(View(awardModel)); } catch (KeyNotFoundException) { return(HttpNotFound()); } }
public ActionResult Details(int id) { try { var user = userLogic.Get(id); var img = user.ImgId > 0 ? GetImgUrl(user) : null; var relatedAwards = user.Awards .Select(e => awardLogic.Get(e)) .Select(e => new AwardModel(e.Title, e.Id)) .ToList(); var availableAwards = awardLogic.GetAll().Values .Select(e => new AwardModel(e.Title, e.Id)) .ToList(); var model = new UserAwardAddingModel( user.Id, user.Name, user.Birthday, relatedAwards, availableAwards, img); return View(model); } catch (KeyNotFoundException) { return HttpNotFound(); } }
private static void GetAward() { System.Console.WriteLine("Enter id"); bool correctId = int.TryParse(System.Console.ReadLine(), out int id); while (!correctId) { System.Console.WriteLine("Incorrect value, try again."); correctId = int.TryParse(System.Console.ReadLine(), out id); } Award award = awardLogic.Get(id); if (award == null) { System.Console.WriteLine("\tNo such user exists"); return; } System.Console.WriteLine("\tAward name:"); System.Console.WriteLine(awardLogic.Get(id)); }