Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public class GiftLists
  2. {
  3. [Column("gift_list_id")]
  4. public int Id { get; set; }
  5.  
  6. [Required]
  7. [Column("name")]
  8. [MaxLength(50)]
  9. public string Name { get; set; }
  10.  
  11. public string UserId { get; set; }
  12. public Users Users { get; set; }
  13.  
  14. [Column("created_on")]
  15. public DateTime CreatedAt { get; set; }
  16.  
  17. public List<GiftItem> GiftItems { get; set; }
  18. }
  19.  
  20. public async Task<int> CreateList(GiftListDto glist)
  21. {
  22. // Check for user in table
  23. var user = await _unitOfWork.Users.GetUserByIdAsync(glist.UserId);
  24. if (user == null)
  25. {
  26. // Already in table
  27. }
  28. else
  29. {
  30. // If not in table, add it.
  31. _unitOfWork.Users.Add(new Users
  32. {
  33. UserId = glist.UserId
  34. });
  35. }
  36.  
  37. //_unitOfWork.GiftLists.Add(new GiftLists
  38. //{
  39. // Name = glist.Name,
  40. // Users = new Users
  41. // {
  42. // UserId = glist.UserId
  43. // }
  44. //});
  45. return await _unitOfWork.CompleteAsync();
  46. }
  47.  
  48. public class GiftListRepository : Repository<GiftLists>, IGiftListRepository
  49. {
  50. public GiftListRepository(ApplicationDbContext context) : base(context)
  51. {
  52. }
  53.  
  54. public override void Add(GiftLists glist)
  55. {
  56. // Check if user exists...
  57. /* If not; add new user via GiftList navigation property
  58. while also adding the GiftList entry */
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement