public void Add(ServiceModel service) { var user = services.GetUser(service.UserID); var category = services.GetCategory(service.CategoryID); var rating = services.CreateRating(); if (user == null) { throw new WojtekException(WojtekCodes.UserNotFound); } if (category == null) { throw new WojtekException(WojtekCodes.CategoryNotFound); } foreach (Service s in services.GetAllUserTwo(service.UserID)) { if (s.ServiceName == service.Name) { throw new WojtekException(WojtekCodes.ActiveName); } } string filename = ImageHelper.WriteImage(service.Image, ProjectLocation.Get + @"\Images"); var newService = new Service(user, category, service.Name, filename.Replace('.', ';'), rating, service.Descryption); services.Add(newService); }
public void AddComment(CommentModel comment) { var user = services.GetUser(comment.UserID); var service = services.Get(comment.ServiceID); var newComment = new Comment(comment.Content, user, service); comments.AddComment(newComment); }