/// <summary> /// Adds a rating of the given type. /// </summary> /// <param name="type">The rating type</param> /// <param name="modelId">The unique model type</param> /// <param name="userId">The user id</param> public void AddRating(Models.RatingType type, Guid modelId, string userId) { var rating = session.Get <Models.Rating>(where : r => r.Type == type && r.ModelId == modelId && r.UserId == userId).SingleOrDefault(); if (rating == null) { session.Add <Models.Rating>(new Models.Rating() { Type = type, ModelId = modelId, UserId = userId }); } }
/// <summary> /// Adds a new model to the current session. /// </summary> /// <param name="model">The model</param> public virtual void Add(T model) { // Ensure id if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); } var errors = Validate(model); if (errors.Count() > 0) { throw new Data.ModelException("Model validation failed", errors); } session.Add <T>(model); }