Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GiftLists
- {
- [Column("gift_list_id")]
- public int Id { get; set; }
- [Required]
- [Column("name")]
- [MaxLength(50)]
- public string Name { get; set; }
- public string UserId { get; set; }
- public Users Users { get; set; }
- [Column("created_on")]
- public DateTime CreatedAt { get; set; }
- public List<GiftItem> GiftItems { get; set; }
- }
- public async Task<int> CreateList(GiftListDto glist)
- {
- // Check for user in table
- var user = await _unitOfWork.Users.GetUserByIdAsync(glist.UserId);
- if (user == null)
- {
- // Already in table
- }
- else
- {
- // If not in table, add it.
- _unitOfWork.Users.Add(new Users
- {
- UserId = glist.UserId
- });
- }
- //_unitOfWork.GiftLists.Add(new GiftLists
- //{
- // Name = glist.Name,
- // Users = new Users
- // {
- // UserId = glist.UserId
- // }
- //});
- return await _unitOfWork.CompleteAsync();
- }
- public class GiftListRepository : Repository<GiftLists>, IGiftListRepository
- {
- public GiftListRepository(ApplicationDbContext context) : base(context)
- {
- }
- public override void Add(GiftLists glist)
- {
- // Check if user exists...
- /* If not; add new user via GiftList navigation property
- while also adding the GiftList entry */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement