public bool AwardUserByUrl(string user_award) { if (string.IsNullOrWhiteSpace(user_award)) { return(false); } var res = user_award.Split('_'); if (res == null || res.Length != 2) { return(false); } int userId = 0; int awardId = 0; int.TryParse(res[0], out userId); int.TryParse(res[1], out awardId); if (userId < ModelRules.LowerBoundOfId || awardId < ModelRules.LowerBoundOfId) { return(false); } if (userBll.GetUserById(userId) == null || awardBll.GetAwardById(awardId) == null) { return(false); } return(AddAwardToUser(userId, awardId)); }
public bool AwardUserByUrl(string user_award) { var res = user_award.Split('_'); if (res == null || res.Length != 2) { return(false); } int userId = 0, awardId = 0; int.TryParse(res[0], out userId); int.TryParse(res[1], out awardId); if (userId <= 0 || awardId <= 0) { return(false); } if (userBll.GetUserById(userId) == null || awardBll.GetAwardById(awardId) == null) { return(false); } return(AddAwardToUser(userId, awardId)); }
//дейтсвия для Awards private static void AwardsAction() { while (true) { Console.WriteLine(); Console.WriteLine($"1: Find award by ID"); Console.WriteLine($"2: Find award by Name"); Console.WriteLine($"3: Find award by the first letter"); Console.WriteLine($"4: Find award whose name includes the entered word"); Console.WriteLine($"5: Delete award"); Console.WriteLine($"6: Edit award"); Console.WriteLine($"7: EXIT"); Console.Write("Choose action: "); var userEnter = Console.ReadLine(); switch (userEnter) { case "1": Console.Write($"Award's ID: "); var id_1 = Console.ReadLine(); var result_1 = awardLogic.GetAwardById(id_1); Console.WriteLine($"{result_1.IdAward} : {result_1.Title} : {result_1.Description}{Environment.NewLine}"); break; case "2": Console.Write($"Award's Title: "); var name_2 = Console.ReadLine(); foreach (var item in awardLogic.GetAwardByTitle(name_2)) { Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}"); } break; case "3": Console.Write($"Write letter: "); var letter_3 = Console.ReadLine(); foreach (var item in awardLogic.GetAwardByLetter(letter_3)) { Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}"); } break; case "4": Console.Write($"Write word: "); var word = Console.ReadLine(); foreach (var item in awardLogic.GetAwardByWord(word)) { Console.WriteLine($"{item.IdAward} : {item.Title} : {item.Description}{Environment.NewLine}"); } break; case "5": Console.Write($"Award's ID: "); var id_5 = Console.ReadLine(); awardLogic.DeleteAward(id_5); break; case "6": Console.Write($"award's ID: "); var id_6 = Console.ReadLine(); var result_6 = awardLogic.GetAwardById(id_6); Console.Write($"award's Titile: "); var title = Console.ReadLine(); Console.Write($"award's Description: "); var description = Console.ReadLine(); awardLogic.UpdateAward(id_6, title, description); break; case "7": return; default: break; } } }
public DisplayAwardVM GetAward(int id) { return(Mapper.Map <DisplayAwardVM>(awardBll.GetAwardById(id))); }
private static Award GetAwardById(IAwardLogic awardLogic, int Id) { return(awardLogic.GetAwardById(Id)); }