Пример #1
0
            public void IfModelRestaurantIDIs0ReturnsModel()
            {
                var model = new Vote { UserId = 1, RestaurantId = 0 };

                var result = _voteLogic.SaveVote(model);

                Assert.Equal(result, model);
            }
Пример #2
0
 public Vote SaveVote(int restaurantID, int userID)
 {
     var entity = new Vote {RestaurantId = restaurantID, UserId = userID};
     return SaveVote(entity);
 }
Пример #3
0
 public Vote SaveVote(Vote entity)
 {
     if (entity == null || entity.UserId == 0 || entity.RestaurantId == 0) return entity;
     var match = _voteRepository.GetItem(entity.UserId, DateTime.Now);
     if (match == null)
     {
         entity.VoteDate = DateTime.Now;
         entity = _voteRepository.SaveOrUpdate(entity);
     }
     return entity;
 }
Пример #4
0
 public Vote SaveOrUpdate(Vote entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         if (entity.Id == 0)
             entity.Id = _connection.Insert(entity);
         else
             _connection.Update(entity);
     }
     return entity;
 }