public void IfModelRestaurantIDIs0ReturnsModel() { var model = new Vote { UserId = 1, RestaurantId = 0 }; var result = _voteLogic.SaveVote(model); Assert.Equal(result, model); }
public Vote SaveVote(int restaurantID, int userID) { var entity = new Vote {RestaurantId = restaurantID, UserId = userID}; return SaveVote(entity); }
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; }
public Vote SaveOrUpdate(Vote entity) { using (_connection = Utilities.GetProfiledOpenConnection()) { if (entity.Id == 0) entity.Id = _connection.Insert(entity); else _connection.Update(entity); } return entity; }