Exemplo n.º 1
0
 static Const()
 {
     AvatarList    = JsonSerializer.Deserialize <List <string> >(File.ReadAllText("Resource\\List\\AvatarList.json"), JsonOptions);
     ZeroWishEvent = new WishEvent
     {
         Name      = "---",
         StartTime = new DateTime(2020, 9, 15, 0, 0, 0, DateTimeKind.Local),
         EndTime   = DateTime.Now,
         UpStar5   = new List <string>(),
         UpStar4   = new List <string>()
     };
 }
Exemplo n.º 2
0
        public void AddWishEvent(int userId, int eventId)
        {
            if (!_unitOfWork.UserRepository.Find(x => x.Id == userId).Any())
            {
                throw new Exception();
            }

            if (!_unitOfWork.EventRepository.Find(x => x.Id == eventId).Any())
            {
                throw new Exception();
            }

            if (!_unitOfWork.WishEventRepository.Find(x => x.UserId == userId && x.EventId == eventId).Any())
            {
                var wishEvent = new WishEvent
                {
                    UserId  = userId,
                    EventId = eventId
                };

                _unitOfWork.WishEventRepository.Add(wishEvent);
                _unitOfWork.SaveChanges();
            }
        }