public IndexAction() { _articleRepository = new ArticleRepository(); _nodeRepository = new NodeRepository(); _articleCategoryRepository = new ArticleCategoryRepository(); _nodeRecordRepository = new NodeRecordRepository(); }
public CompositeController() { _articleRepository = new ArticleRepository(UnitOfWork); _bioRepository = new BioRepository(UnitOfWork); _eventRepository = new EventRepository(UnitOfWork); _qaRepository = new QARepository(UnitOfWork); _downloadRepository = new DownloadRepository(UnitOfWork); _searchRepository = new SearchRepository(UnitOfWork); }
/// <summary> /// ctor /// </summary> public UnitOfWork(IBreezeValidator breezevalidator) { contextProvider = new EFContextProvider<DurandalAuthDbContext>(); contextProvider.BeforeSaveEntitiesDelegate = breezevalidator.BeforeSaveEntities; contextProvider.BeforeSaveEntityDelegate = breezevalidator.BeforeSaveEntity; ArticleRepository = new ArticleRepository(contextProvider.Context); CategoryRepository = new Repository<Category>(contextProvider.Context); TagRepository = new Repository<Tag>(contextProvider.Context); UserProfileRepository = new Repository<UserProfile>(contextProvider.Context); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting( filterContext); _database = new DatabaseWithMVCMiniProfilerAndGlimpse( "PetaPocoWebTest"); _database.EnsureDatabase(); _tags = new TagRepository( _database); _articles = new ArticleRepository( _tags, _database); _authors = new AuthorRepository( _database); HttpContext.Items[DatabaseWithGlimpseProfiling.PetaKey] = TempData[DatabaseWithGlimpseProfiling.PetaKey]; }
public ArticleController(ArticleRepository articleRepository) { db = articleRepository; }
public Article GetParentArticle(int articleId) => ArticleRepository.GetById(articleId);
public ArticleService(ArticleRepository articleRepository) { _articleRepository = articleRepository; }
public ArticlesViewComponent(IArticleRepository articleRepository) { _articleRepository = (ArticleRepository)articleRepository; }
public IList <EntityTreeItem> Process() { var treeField = FieldRepository.GetById(ContentRepository.GetTreeFieldId(_parentEntityId)); return(ArticleRepository.GetArticlesTreeForFtsResult(_commonFilter, treeField, _filterQuery, _linkedFilters, _contextQuery, _filterSqlParams, _extensionContentIds, _ftsOptions).ToList()); }
public ActionResult Articles() { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Default")); } List <Article> articleList = new List <Article>(); ArticleRepository articleRepository = new ArticleRepository(); Dictionary <int, List <Comment> > comments = new Dictionary <int, List <Comment> >(); CommentRepository commentRepository = new CommentRepository(); Dictionary <int, string> userDictionary = new Dictionary <int, string>(); List <int> subjectId = new List <int>(); Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); Student student = new Student(); StudentRepository studentRepository = new StudentRepository(); List <Article> list = new List <Article>(); if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher))) { teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); foreach (var item in teacher.CourseSubject) { subjectId.Add(item.Subject.Id); } } else if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Student))) { student = studentRepository.GetById(AuthenticationManager.LoggedUser.Id); List <CourseSubject> courseSubjectList = new List <CourseSubject>(); CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository(); courseSubjectList = courseSubjectRepository.GetAll(filter: cs => cs.CourseID == student.CourseID); foreach (var item in courseSubjectList) { subjectId.Add(item.Subject.Id); } } subjectId = subjectId.Distinct().ToList(); foreach (var item in subjectId) { List <Article> article = articleRepository.GetAll(filter: s => s.Subject.Id == item); if (article != null) { articleList.AddRange(article); } } articleList = articleList.OrderBy(d => d.DateCreated.TimeOfDay).ToList(); articleList.Reverse(); ArticleControllerArticlesVM model = new ArticleControllerArticlesVM(); LikeRepository likeRepository = new LikeRepository(); Dictionary <Article, int> ArticlesAndLikeCount = new Dictionary <Article, int>(); Dictionary <int, bool> Liked = new Dictionary <int, bool>(); int articleId = 0; string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString(); int start = type.LastIndexOf(".") + 1; int positions = type.Length - start; type = type.Substring(start, positions); foreach (var item in articleList) { List <Comment> commentedCommentList = new List <Comment>(); commentedCommentList = commentRepository.GetAll(filter: c => c.Article.Id == item.Id); commentedCommentList.OrderBy(c => c.DateCreated.TimeOfDay).ToList(); commentedCommentList.Reverse(); foreach (var comment in commentedCommentList) { string userName = ""; if (comment.UserType == "Teacher") { teacher = teacherRepository.GetById(comment.UserID); if (teacher != null) { userName = teacher.FirstName + " " + teacher.LastName; userDictionary.Add(comment.Id, userName); } } else { student = studentRepository.GetById(comment.UserID); userName = student.FirstName + " " + student.LastName; userDictionary.Add(comment.Id, userName); } } comments.Add(item.Id, commentedCommentList); int count = likeRepository.GetAll(filter: a => a.ArticleID == item.Id).Count; ArticlesAndLikeCount.Add(item, count); List <Like> likes = new List <Like>(); likes = likeRepository.GetAll(l => l.ArticleID == item.Id); foreach (var like in likes.Where(l => l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type)) { Liked.Add(item.Id, true); } model.ArticleId = item.Id; if (Liked.Count != ArticlesAndLikeCount.Count) { foreach (var dictionary in ArticlesAndLikeCount.Where(a => a.Key.Id == item.Id)) { articleId = item.Id; } Liked.Add(articleId, false); } } model.UserType = type; model.IsLiked = Liked; model.UserID = AuthenticationManager.LoggedUser.Id; model.Articles = ArticlesAndLikeCount; model.CommentList = comments; model.UserDictionary = userDictionary; return(View(model)); }
public ActionResult EditArticle(int id) { if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher))) { ArticleControllerArticlesVM model = new ArticleControllerArticlesVM(); TeacherRepository teacherRepository = new TeacherRepository(); Article article = new Article(); ArticleRepository articleRepository = new ArticleRepository(); List<Subject> subjectList = new List<Subject>(); SubjectRepository subjectRepository = new SubjectRepository(); Teacher teacher = new Teacher(); List<SelectListItem> listSubjects = new List<SelectListItem>(); teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); List<int> subjectId = new List<int>(); foreach (var item in teacher.CourseSubject) { subjectId.Add(item.Subject.Id); } subjectId = subjectId.Distinct().ToList(); foreach (var item in subjectId) { subjectList.Add(subjectRepository.GetById(item)); } if (id > 0) { article = articleRepository.GetById(id); model.ArticleId = article.Id; model.TeacherID = teacher.Id; model.Title = article.Title; model.Content = article.Content; model.DateCreated = article.DateCreated; model.DateModified = article.DateModified; model.Subject = article.Subject; model.Teacher = teacher; listSubjects.Add(new SelectListItem() { Text = article.Subject.Name, Value = article.Subject.Id.ToString(), Selected = true }); } if (id == 0) { model.ArticleId = 0; listSubjects.Add(new SelectListItem() { Text = "Select subject", Value = "" }); } foreach (var item in subjectList) { if (item.Id != model.ArticleId) { listSubjects.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } model.SubjectsListItems = listSubjects; return View(model); } return RedirectToAction("Articles"); }
public ArticleRepositoryTests() { _articleRepositoryMock = new Mock <ArticleRepository>(new CrossBlogDbContext(CreateDbContextOptions())); _articleRepository = _articleRepositoryMock.Object; }
public void EditProductJustDocument() { var inizio = DateTime.Now; IDocumentRepository docRep = new DocumentRepository(); IProductRepository prodRep = new ProductRepository(); PapiroService p = new PapiroService(); p.DocumentRepository = docRep; p.CostDetailRepository = new CostDetailRepository(); p.TaskExecutorRepository = new TaskExecutorRepository(); p.ArticleRepository = new ArticleRepository(); Document doc = docRep.GetEstimateEcommerce("000001"); doc.EstimateNumber = "0"; DocumentProduct dp = docRep.GetDocumentProductsByCodProduct("").FirstOrDefault(); //work with product Product prod = p.InitProduct("SuppRigidi", new ProductTaskNameRepository(), new FormatsNameRepository(), new TypeOfTaskRepository()); //------passaggio del prodotto inizializzato all'ecommerce o alla view prod.CodProduct = prodRep.GetNewCode(prod); prod.ProductParts.FirstOrDefault().Format = "15x21"; prod.ProductParts.FirstOrDefault().SubjectNumber = 1; var art = prod.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault(); #region Printable Article IArticleRepository artRep = new ArticleRepository(); var artFormList = artRep.GetAll().OfType<RigidPrintableArticle>().FirstOrDefault(); art.TypeOfMaterial = artFormList.TypeOfMaterial; art.NameOfMaterial = artFormList.NameOfMaterial; art.Weight = artFormList.Weight; art.Color = artFormList.Color; #endregion //------ritorno del prodotto modificato!!!! //rigenero prodRep.Add(prod); prodRep.Save(); #region ViewModel ProductViewModel pv = new ProductViewModel(); pv.Product = prod; // prod.ProductCodeRigen(); pv.Quantity = 10; #endregion p.EditOrCreateAllCost(dp.CodDocumentProduct); var fine = DateTime.Now.Subtract(inizio).TotalSeconds; Assert.IsTrue(fine < 4); }
public JsonResult Like(int id, string value) { bool success = false; Like like = new Like(); Article article = new Article(); ArticleRepository articleRepository = new ArticleRepository(); LikeRepository likeRepository = new LikeRepository(); article = articleRepository.GetById(id); List<Like> likeList = new List<Like>(); string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString(); int start = type.LastIndexOf(".") + 1; int positions = type.Length - start; type = type.Substring(start, positions); if (value == "Like") { like.ArticleID = id; like.UserID = AuthenticationManager.LoggedUser.Id; like.UserType = type; likeRepository.Save(like); success = true; } if (value == "UnLike") { like = likeRepository.GetAll(filter: l => l.ArticleID == id && l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type).FirstOrDefault(); likeRepository.Delete(like); success = true; } return Json(success, JsonRequestBehavior.AllowGet); }
public ActionResult EditArticle(ArticleControllerArticlesVM model) { TryUpdateModel(model); if (model.SubjectID < 1 || !ModelState.IsValid) { model.ArticleId = 0; List<CourseSubject> courseSubject = new List<CourseSubject>(); Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); courseSubject = teacher.CourseSubject.ToList(); List<SelectListItem> listSubjects = new List<SelectListItem>(); listSubjects.Add(new SelectListItem() { Text = "Select subject", Value = "" }); foreach (var item in courseSubject) { if (item.Subject.Id != model.ArticleId) { listSubjects.Add(new SelectListItem() { Text = item.Subject.Name, Value = item.Subject.Id.ToString() }); } } model.SubjectsListItems = listSubjects; } if (ModelState.IsValid) { Article article = new Article(); ArticleRepository articleRepository = new ArticleRepository(); Subject subject = new Subject(); SubjectRepository subjectRepository = new SubjectRepository(); Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); if (model.ArticleId > 0) { article = articleRepository.GetById(model.ArticleId); article.Content = model.Content; article.DateCreated = model.DateCreated; article.DateModified = DateTime.Now; article.SubjectID = model.SubjectID; article.TeacherID = teacher.Id; article.Title = model.Title; } else { article.Content = model.Content; article.DateCreated = DateTime.Now; article.SubjectID = model.SubjectID; article.TeacherID = teacher.Id; article.Title = model.Title; } articleRepository.Save(article); return RedirectToAction("Articles"); } return View(model); }
public async Task ArticleRepositoryAllMethodTest() { //[0] DbContextOptions<T> Object Creation var options = new DbContextOptionsBuilder <ArticleAppDbContext>() .UseInMemoryDatabase(databaseName: $"ArticleApp{Guid.NewGuid()}").Options; //.UseSqlServer("server=(localdb)\\mssqllocaldb;database=ArticleApp;integrated security=true;").Options; //[1] AddAsync() Method Test //[1][1] Repository 클래스를 사용하여 저장 using (var context = new ArticleAppDbContext(options)) { // Repository Object Creation //[!] Arrange var repository = new ArticleRepository(context); var model = new Article { Title = "[1] 게시판 시작", Created = DateTime.Now }; //[!] Act: AddAsync() 메서드 테스트 await repository.AddArticleAsync(model); await context.SaveChangesAsync(); // 이 코드는 생략 가능 } //[1][2] DbContext 클래스를 통해서 개수 및 레코드 확인 using (var context = new ArticleAppDbContext(options)) { //[!] Assert Assert.AreEqual(1, await context.Articles.CountAsync()); var model = await context.Articles.Where(m => m.Id == 1).SingleOrDefaultAsync(); Assert.AreEqual("[1] 게시판 시작", model?.Title); } //[2] GetAllAsync() Method Test using (var context = new ArticleAppDbContext(options)) { // 트랜잭션 관련 코드는 InMemoryDatabase 공급자에서는 지원 X // using (var transaction = context.Database.BeginTransaction()) { transaction.Commit(); } var repository = new ArticleRepository(context); var model = new Article { Title = "[2] 게시판 가동", Created = DateTime.Now }; await context.Articles.AddAsync(model); await context.SaveChangesAsync(); //[1] await context.Articles.AddAsync(new Article { Title = "[3] 게시판 중지", Created = DateTime.Now }); await context.SaveChangesAsync(); //[2] } using (var context = new ArticleAppDbContext(options)) { var repository = new ArticleRepository(context); var models = await repository.GetArticlesAsync(); Assert.AreEqual(3, models.Count); } //[3] GetByIdAsync() Method Test using (var context = new ArticleAppDbContext(options)) { // Empty } using (var context = new ArticleAppDbContext(options)) { var repository = new ArticleRepository(context); var model = await repository.GetArticleByIdAsync(2); Assert.IsTrue(model.Title.Contains("가동")); Assert.AreEqual("[2] 게시판 가동", model.Title); } //[4] GetEditAsync() Method Test using (var context = new ArticleAppDbContext(options)) { // Empty } using (var context = new ArticleAppDbContext(options)) { var repository = new ArticleRepository(context); var model = await repository.GetArticleByIdAsync(2); model.Title = "[2] 게시판 바쁨"; await repository.EditArticleAsync(model); await context.SaveChangesAsync(); // 생략가능 - 저장 시점을 코드로 표현하기 위함 Assert.AreEqual("[2] 게시판 바쁨", (await context.Articles.Where(m => m.Id == 2).SingleOrDefaultAsync()).Title); } //[5] GetDeleteAsync() Method Test using (var context = new ArticleAppDbContext(options)) { // Empty } using (var context = new ArticleAppDbContext(options)) { var repository = new ArticleRepository(context); await repository.DeleteArticleAsync(2); await context.SaveChangesAsync(); Assert.AreEqual(2, await context.Articles.CountAsync()); Assert.IsNull(await repository.GetArticleByIdAsync(2)); } //[6] PagingAsync() Method Test using (var context = new ArticleAppDbContext(options)) { // Empty } using (var context = new ArticleAppDbContext(options)) { int pageIndex = 0; int pageSize = 1; var repository = new ArticleRepository(context); var models = await repository.GetAllAsync(pageIndex, pageSize); Assert.AreEqual("[3] 게시판 중지", models.Records.FirstOrDefault().Title); Assert.AreEqual(2, models.TotalRecords); } }
public ActionResult DeleteArticle(int id) { if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher))) { Article article = new Article(); ArticleRepository articleRepository = new ArticleRepository(); article = articleRepository.GetById(id); articleRepository.Delete(article); return RedirectToAction("Articles"); } return RedirectToAction("Articles"); }
public ParserController(ApplicationDbContext context) { _context = context; _userRepository = new UserRepository(_context); _articleRepository = new ArticleRepository(_context); }
public ActionResult Articles() { if (AuthenticationManager.LoggedUser == null) { return RedirectToAction("Login", "Default"); } List<Article> articleList = new List<Article>(); ArticleRepository articleRepository = new ArticleRepository(); Dictionary<int, List<Comment>> comments = new Dictionary<int, List<Comment>>(); CommentRepository commentRepository = new CommentRepository(); Dictionary<int, string> userDictionary = new Dictionary<int, string>(); List<int> subjectId = new List<int>(); Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); Student student = new Student(); StudentRepository studentRepository = new StudentRepository(); List<Article> list = new List<Article>(); if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher))) { teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); foreach (var item in teacher.CourseSubject) { subjectId.Add(item.Subject.Id); } } else if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Student))) { student = studentRepository.GetById(AuthenticationManager.LoggedUser.Id); List<CourseSubject> courseSubjectList = new List<CourseSubject>(); CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository(); courseSubjectList = courseSubjectRepository.GetAll(filter: cs => cs.CourseID == student.CourseID); foreach (var item in courseSubjectList) { subjectId.Add(item.Subject.Id); } } subjectId = subjectId.Distinct().ToList(); foreach (var item in subjectId) { List<Article> article = articleRepository.GetAll(filter: s => s.Subject.Id == item); if (article != null) { articleList.AddRange(article); } } articleList = articleList.OrderBy(d => d.DateCreated.TimeOfDay).ToList(); articleList.Reverse(); ArticleControllerArticlesVM model = new ArticleControllerArticlesVM(); LikeRepository likeRepository = new LikeRepository(); Dictionary<Article, int> ArticlesAndLikeCount = new Dictionary<Article, int>(); Dictionary<int, bool> Liked = new Dictionary<int, bool>(); int articleId = 0; string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString(); int start = type.LastIndexOf(".") + 1; int positions = type.Length - start; type = type.Substring(start, positions); foreach (var item in articleList) { List<Comment> commentedCommentList = new List<Comment>(); commentedCommentList = commentRepository.GetAll(filter: c => c.Article.Id == item.Id); commentedCommentList.OrderBy(c => c.DateCreated.TimeOfDay).ToList(); commentedCommentList.Reverse(); foreach (var comment in commentedCommentList) { string userName = ""; if (comment.UserType == "Teacher") { teacher = teacherRepository.GetById(comment.UserID); if (teacher != null) { userName = teacher.FirstName + " " + teacher.LastName; userDictionary.Add(comment.Id, userName); } } else { student = studentRepository.GetById(comment.UserID); userName = student.FirstName + " " + student.LastName; userDictionary.Add(comment.Id, userName); } } comments.Add(item.Id, commentedCommentList); int count = likeRepository.GetAll(filter: a => a.ArticleID == item.Id).Count; ArticlesAndLikeCount.Add(item, count); List<Like> likes = new List<Like>(); likes = likeRepository.GetAll(l => l.ArticleID == item.Id); foreach (var like in likes.Where(l => l.UserID == AuthenticationManager.LoggedUser.Id && l.UserType == type)) { Liked.Add(item.Id, true); } model.ArticleId = item.Id; if (Liked.Count != ArticlesAndLikeCount.Count) { foreach (var dictionary in ArticlesAndLikeCount.Where(a => a.Key.Id == item.Id)) { articleId = item.Id; } Liked.Add(articleId, false); } } model.UserType = type; model.IsLiked = Liked; model.UserID = AuthenticationManager.LoggedUser.Id; model.Articles = ArticlesAndLikeCount; model.CommentList = comments; model.UserDictionary = userDictionary; return View(model); }
public static string GetArticleFieldValue(int contentId, string fieldName, int articleId) => ArticleRepository.GetFieldValue(articleId, contentId, fieldName);
public ArticleService( ArticleRepository articleRepository) { this.articleRepository = articleRepository; }
public SingleModel() { articleRepository = new ArticleRepository(); }
private List <int> GetExistingArticleIds(List <int> articlesIdList) => ArticleRepository.CheckForArticleExistence(articlesIdList, string.Empty, _contentId);
public ActionResult EditArticle(int id) { if (AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher))) { ArticleControllerArticlesVM model = new ArticleControllerArticlesVM(); TeacherRepository teacherRepository = new TeacherRepository(); Article article = new Article(); ArticleRepository articleRepository = new ArticleRepository(); List <Subject> subjectList = new List <Subject>(); SubjectRepository subjectRepository = new SubjectRepository(); Teacher teacher = new Teacher(); List <SelectListItem> listSubjects = new List <SelectListItem>(); teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id); List <int> subjectId = new List <int>(); foreach (var item in teacher.CourseSubject) { subjectId.Add(item.Subject.Id); } subjectId = subjectId.Distinct().ToList(); foreach (var item in subjectId) { subjectList.Add(subjectRepository.GetById(item)); } if (id > 0) { article = articleRepository.GetById(id); model.ArticleId = article.Id; model.TeacherID = teacher.Id; model.Title = article.Title; model.Content = article.Content; model.DateCreated = article.DateCreated; model.DateModified = article.DateModified; model.Subject = article.Subject; model.Teacher = teacher; listSubjects.Add(new SelectListItem() { Text = article.Subject.Name, Value = article.Subject.Id.ToString(), Selected = true }); } if (id == 0) { model.ArticleId = 0; listSubjects.Add(new SelectListItem() { Text = "Select subject", Value = "" }); } foreach (var item in subjectList) { if (item.Id != model.ArticleId) { listSubjects.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } } model.SubjectsListItems = listSubjects; return(View(model)); } return(RedirectToAction("Articles")); }
private Dictionary <string, int> GetExistingArticleIdsMap(List <string> values, string fieldName) => ArticleRepository.GetExistingArticleIdsMap(values, fieldName, string.Empty, _contentId);
public SeriesArticle() { _repository = new ArticleRepository(); }
internal static IEnumerable <EntityObject> GetList(string entityTypeCode, IList <int> ids) { if (entityTypeCode.Equals(EntityTypeCode.CustomerCode, StringComparison.InvariantCultureIgnoreCase) && ids.Any()) { return(new EntityObject[] { new CustomerObject { Id = ids.First(), Modified = DateTime.MinValue, IsReadOnly = true } }); } if (entityTypeCode.Equals(EntityTypeCode.Site, StringComparison.InvariantCultureIgnoreCase)) { return(SiteRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Content, StringComparison.InvariantCultureIgnoreCase)) { return(ContentRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Field, StringComparison.InvariantCultureIgnoreCase)) { return(FieldRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Article, StringComparison.InvariantCultureIgnoreCase)) { return(ArticleRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Notification, StringComparison.InvariantCultureIgnoreCase)) { return(NotificationRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorPlugin, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetPluginList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorCommand, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetCommandList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VisualEditorStyle, StringComparison.InvariantCultureIgnoreCase)) { return(VisualEditorRepository.GetStyleList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.StatusType, StringComparison.InvariantCultureIgnoreCase)) { return(StatusTypeRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Workflow, StringComparison.InvariantCultureIgnoreCase)) { return(WorkflowRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.PageTemplate, StringComparison.InvariantCultureIgnoreCase)) { return(PageTemplateRepository.GetPageTemplateList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.User, StringComparison.InvariantCultureIgnoreCase)) { return(UserRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.UserGroup, StringComparison.InvariantCultureIgnoreCase)) { return(UserGroupRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.TemplateObjectFormat, StringComparison.InvariantCultureIgnoreCase)) { return(FormatRepository.GetList(ids, false)); } if (entityTypeCode.Equals(EntityTypeCode.PageObjectFormat, StringComparison.InvariantCultureIgnoreCase)) { return(FormatRepository.GetList(ids, true)); } if (entityTypeCode.Equals(EntityTypeCode.PageObject, StringComparison.InvariantCultureIgnoreCase) || entityTypeCode.Equals(EntityTypeCode.TemplateObject, StringComparison.InvariantCultureIgnoreCase)) { return(ObjectRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.VirtualContent, StringComparison.InvariantCultureIgnoreCase)) { return(VirtualContentRepository.GetList(ids)); } if (entityTypeCode.Equals(EntityTypeCode.Page, StringComparison.InvariantCultureIgnoreCase)) { return(PageRepository.GetList(ids)); } return(Enumerable.Empty <EntityObject>()); }
public int CountDuplicates(int id) => ArticleRepository.CountDuplicates(this, null, id);
public ArticlesController(ArticleRepository articleRepository) { _articleRepository = articleRepository; }
public ArticleServiceTest() { IArticleRepository articleRepository = new ArticleRepository(InMemoryStorage.Instance); this._articleService = new ArticleService(articleRepository, new ConsoleLogger <ArticleService>()); }
public IndexModel() { ArticleRepository = new ArticleRepository(); }
public TagsController(ArticleRepository articles) => _articles = articles;
public static void Main(string[] args) { Console.WriteLine("----------- Strategy Pattern ------------"); var husky = new Husky(); husky.Bark(); husky.Run(); husky.SetBarkBehavior(new BarkElectronical()); husky.Bark(); Console.WriteLine("----------- Singleton ------------"); var bankValues1 = BankValues.GetInstance(); var bankValues2 = BankValues.GetInstance(); Console.WriteLine(bankValues1 == bankValues2 ? "Oh yes, I am the same instance" : "Nope, I am another BankValue instance."); Console.WriteLine("----------- Factory Method ------------"); var shop = new SoftwareShop().GetProgram(OfficeProg.Powerpoint); Console.WriteLine("----------- Facade ------------"); var officeTask = new OfficeFacade(); officeTask.PrintDocument(); Console.WriteLine("----------- State ------------"); var lumpi = new Doggy(); lumpi.Play(); lumpi.Anger(); lumpi.GiveMeal(); lumpi.Stroke(); lumpi.LeaveAlone(); Console.WriteLine("----------- DI with Autofac ------------"); var container = ContainerConfig.Configure(); using (var scope = container.BeginLifetimeScope()) { var app = scope.Resolve <IApplication>(); app.Run(); } Console.WriteLine("----------- Repository ------------"); ArticleRepository artRepo = new ArticleRepository(); List <Article> artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); artRepo.Create(new Article { }); var artLatest = artRepo.ReadLatest(); Console.WriteLine($"Title: {artLatest.Title}, ID: {artLatest.Id}"); artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); artRepo.Update(new Article { }); Console.WriteLine($"FOUND: {artRepo.ReadById(1).Title}"); artRepo.Delete(new Article { }); artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); }
private void WriteFieldValues() { var articles = GetArticlesForExport(_settings.FieldsToExpandSettings); var aliases = _settings.FieldsToExpandSettings.Select(n => n.Alias).ToArray(); var fields = _extensionContents.SelectMany(c => c.Fields).Concat(FieldRepository.GetFullList(_contentId)).ToList(); var ids = articles.AsEnumerable().Select(n => (int)n.Field <decimal>("content_item_id")).ToArray(); var extensionIdsMap = _extensionContents.ToDictionary(c => c.Id, c => articles .AsEnumerable() .Select(n => n.Field <decimal?>(string.Format(FieldNameHeaderTemplate, c.Name, IdentifierFieldName))) .Where(n => n.HasValue) .Select(n => (int)n.Value) .ToArray() ); if (articles.Any()) { var dict = fields .Where(n => n.ExactType == FieldExactTypes.M2MRelation && articles[0].Table.Columns.Contains(n.ContentId == _contentId ? n.Name : string.Format(FieldNameHeaderTemplate, n.Content.Name, n.Name))) .Select(n => new { LinkId = n.LinkId.Value, n.ContentId }) .ToDictionary(n => n.LinkId.ToString(), m => ArticleRepository.GetLinkedItemsMultiple(m.LinkId, m.ContentId == _contentId ? ids : extensionIdsMap[m.ContentId], true)); var m2oFields = fields.Where(w => w.ExactType == FieldExactTypes.M2ORelation).ToArray(); foreach (var field in m2oFields) { var m2ODisplayFieldName = ContentRepository.GetTitleName(field.BackRelation.ContentId); var m2OValues = ArticleRepository.GetM2OValues(articles.AsEnumerable().Select(n => (int)n.Field <decimal>("content_item_id")).ToList(), field.BackRelation.ContentId, field.Id, field.BackRelation.Name, m2ODisplayFieldName); foreach (var value in m2OValues) { var key = value.Key.Item1 + "_" + value.Key.Item2; dict.Add(key, new Dictionary <int, string>() { { value.Key.Item1, string.Join(",", value.Value) } }); } } foreach (var article in articles) { _sb.Append(_contentId); _sb.Append(_settings.Delimiter); _sb.AppendFormat("{0}{1}", article["content_item_id"], _settings.Delimiter); foreach (DataColumn column in article.Table.Columns) { var value = article[column.ColumnName].ToString(); var field = fields.FirstOrDefault(f => f.ContentId == _contentId ? string.Equals(f.Name, column.ColumnName, StringComparison.InvariantCultureIgnoreCase) : string.Equals(string.Format(FieldNameHeaderTemplate, f.Content.Name, f.Name), column.ColumnName, StringComparison.InvariantCultureIgnoreCase)); var alias = aliases.FirstOrDefault(n => aliases.Contains(column.ColumnName, StringComparer.InvariantCultureIgnoreCase)); if (!string.IsNullOrEmpty(alias)) { _sb.AppendFormat("{0}{1}", FormatFieldValue(value), _settings.Delimiter); } else if (field != null) { _sb.AppendFormat("{0}{1}", FormatFieldValue(article, value, field, dict), _settings.Delimiter); } else if (_extensionContents.Any(c => string.Equals(string.Format(FieldNameHeaderTemplate, c.Name, IdentifierFieldName), column.ColumnName, StringComparison.InvariantCultureIgnoreCase))) { _sb.AppendFormat("{0}{1}", string.IsNullOrEmpty(value) ? "NULL" : value, _settings.Delimiter); } } if (!_settings.ExcludeSystemFields) { foreach (var fieldValue in new[] { MultistepActionHelper.DateCultureFormat( article[FieldName.Created].ToString(), CultureInfo.CurrentCulture.Name, _settings.Culture), MultistepActionHelper.DateCultureFormat( article[FieldName.Modified].ToString(), CultureInfo.CurrentCulture.Name, _settings.Culture ), article[FieldName.UniqueId].ToString(), "0" }) { _sb.Append(fieldValue); _sb.Append(_settings.Delimiter); } } _sb.Append(_settings.LineSeparator); } } Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); using (var sw = new StreamWriter(_settings.UploadFilePath, true, Encoding.GetEncoding(_settings.Encoding))) { sw.Write(_sb.ToString()); } _processedItemsCount = articles.Count; }
private void LoadRepositories() { userRepository = new UserRepository(new CSVStream <User>(userFile, new UserConverter()), new ComplexSequencer()); // USER OK roomRepository = new RoomRepository(new CSVStream <Room>(roomFile, new RoomConverter()), new LongSequencer()); // ROOM OK inventoryItemRepository = new InventoryItemRepository(new CSVStream <InventoryItem>(inventoryItemFile, new InventoryItemConverter()), new LongSequencer(), roomRepository); timeTableRepository = new TimeTableRepository(new CSVStream <TimeTable>(timeTableFile, new TimeTableConverter()), new LongSequencer()); // TIMETABLE OK hospitalRepository = new HospitalRepository(new CSVStream <Hospital>(hospitalFile, new HospitalConverter()), new LongSequencer(), roomRepository); // HOSPITAL OK secretaryRepository = new SecretaryRepository(new CSVStream <Secretary>(secretaryFile, new SecretaryConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, userRepository); // SECRETARY OK managerRepository = new ManagerRepository(new CSVStream <Manager>(managerFile, new ManagerConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, userRepository); // MANAGER OK doctorRepository = new DoctorRepository(new CSVStream <Doctor>(doctorFile, new DoctorConverter()), new ComplexSequencer(), timeTableRepository, hospitalRepository, roomRepository, userRepository); // DOCTOR OK patientRepository = new PatientRepository(new CSVStream <Patient>(patientFile, new PatientConverter()), new ComplexSequencer(), doctorRepository, userRepository); // PATIENT OK hospitalRepository.DoctorRepository = doctorRepository; hospitalRepository.ManagerRepository = managerRepository; hospitalRepository.SecretaryRepository = secretaryRepository; //Misc repositories locationRepository = new LocationRepository(new CSVStream <Location>(locationFile, new LocationConverter()), new LongSequencer()); // LOCATION OK notificationRepository = new NotificationRepository(new CSVStream <Notification>(notificationFile, new NotificationConverter()), new LongSequencer(), patientRepository, doctorRepository, managerRepository, secretaryRepository); // NOTIFICATION OK messageRepository = new MessageRepository(new CSVStream <Message>(messageFile, new MessageConverter()), new LongSequencer(), patientRepository, doctorRepository, managerRepository, secretaryRepository); // MESSAGE OK articleRepository = new ArticleRepository(new CSVStream <Article>(articleFile, new ArticleConverter()), new LongSequencer(), doctorRepository, managerRepository, secretaryRepository); //ARTICLE OK questionRepository = new QuestionRepository(new CSVStream <Question>(questionFile, new QuestionConverter()), new LongSequencer()); // QUESTION OK doctorQuestionRepository = new QuestionRepository(new CSVStream <Question>(doctorQuestionFile, new QuestionConverter()), new LongSequencer()); //DOCTOR QUESTION OK feedbackRepository = new FeedbackRepository(new CSVStream <Feedback>(feedbackFile, new FeedbackConverter()), new LongSequencer(), questionRepository, patientRepository, doctorRepository, managerRepository, secretaryRepository); doctorFeedbackRepository = new DoctorFeedbackRepository(new CSVStream <DoctorFeedback>(doctorFeedbackFile, new DoctorFeedbackConverter()), new LongSequencer(), doctorQuestionRepository, patientRepository, doctorRepository); //Hospital management repositories symptomRepository = new SymptomRepository(new CSVStream <Symptom>(symptomsFile, new SymptomConverter()), new LongSequencer()); //SYMPTOM REPO OK diseaseRepository = new DiseaseRepository(new CSVStream <Disease>(diseaseFile, new DiseaseConverter()), new LongSequencer(), medicineRepository, symptomRepository); //DISEASE REPO OK ingredientRepository = new IngredientRepository(new CSVStream <Ingredient>(ingredientFile, new IngredientConverter()), new LongSequencer()); //INGREDIENT REPO OK medicineRepository = new MedicineRepository(new CSVStream <Medicine>(medicineFile, new MedicineConverter()), new LongSequencer(), ingredientRepository, diseaseRepository); //MEDICINE REPO OK prescriptionRepository = new PrescriptionRepository(new CSVStream <Prescription>(prescriptionFile, new PrescriptionConverter()), new LongSequencer(), doctorRepository, medicineRepository); //PRESCRIPTION REPO OK //Medical repositories allergyRepository = new AllergyRepository(new CSVStream <Allergy>(allergyFile, new AllergyConverter()), new LongSequencer(), ingredientRepository, symptomRepository); //ALLERGY REPO OK appointmentRepository = new AppointmentRepository(new CSVStream <Appointment>(appointmentsFile, new AppointmentConverter()), new LongSequencer(), patientRepository, doctorRepository, roomRepository); //GERGO REPO OK? therapyRepository = new TherapyRepository(new CSVStream <Therapy>(therapyFile, new TherapyConverter()), new LongSequencer(), medicalRecordRepository, medicalRecordRepository, prescriptionRepository, diagnosisRepository); //med record medicalRecordRepository = new MedicalRecordRepository(new CSVStream <MedicalRecord>(medicalRecordFile, new MedicalRecordConverter()), new LongSequencer(), patientRepository, diagnosisRepository, allergyRepository); //u medical record moras da set diagnosis repo diagnosisRepository = new DiagnosisRepository(new CSVStream <Diagnosis>(diagnosisFile, new DiagnosisConverter()), new LongSequencer(), therapyRepository, diseaseRepository, medicalRecordRepository); //therapy // therapyRepository = new TherapyRepository(new CSVStream<Therapy>(therapyFile,new TherapyConverter()),new LongSequencer(),medicalRecordRepository, ) diseaseRepository.MedicineEagerCSVRepository = medicineRepository; medicineRepository.DiseaseRepository = diseaseRepository; medicalRecordRepository.DiagnosisRepository = diagnosisRepository; diagnosisRepository.MedicalRecordRepository = medicalRecordRepository; diagnosisRepository.TherapyEagerCSVRepository = therapyRepository; therapyRepository.DiagnosisCSVRepository = diagnosisRepository; therapyRepository.MedicalRecordRepository = medicalRecordRepository; therapyRepository.MedicalRecordEagerCSVRepository = medicalRecordRepository; //ODAVDDE RADITI OSTALE doctorStatisticRepository = new DoctorStatisticRepository(new CSVStream <StatsDoctor>(doctorStatisticsFile, new DoctorStatisticsConverter(",")), new LongSequencer(), doctorRepository); // Doc Stats OK inventoryStatisticRepository = new InventoryStatisticsRepository(new CSVStream <StatsInventory>(inventoryStatisticsFile, new InventoryStatisticsConverter(",")), new LongSequencer(), medicineRepository, inventoryItemRepository); // InventoryStats OK roomStatisticRepository = new RoomStatisticsRepository(new CSVStream <StatsRoom>(roomStatisticsFile, new RoomStatisticsConverter(",")), new LongSequencer(), roomRepository); // RoomStats OK inventoryRepository = new InventoryRepository(new CSVStream <Inventory>(inventoryFile, new InventoryConverter(",", ";")), new LongSequencer(), inventoryItemRepository, medicineRepository); }
static void Main(string[] args) { EventLog.WriteEntry("Application", "START SYNC SAGE DB"); Debug.Print("GetCommandLineArgs: {0}", string.Join(", ", args)); try { // Check le rep de log if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } // Purge les fichiers de log > 1 semaine new DirectoryInfo(logDir).GetFiles("*.log", SearchOption.TopDirectoryOnly) .Where(f => f.LastWriteTime < DateTime.Now.AddDays(-7)) .ToList().ForEach(f => { f.Delete(); }); var dbList = new DatabaseList(); // Base source (toujours le premier argument) Database sourceDb = dbList.First(d => d.name == args[0]); /** * DeployScript sur la première base * uniquement si un seul argument * cela permet d'isoler le deploiement des scripts sql * sur TARIF et permet de sync TARIF sur les bases de dev */ if (args.Length == 1) { Log("[DISCONNECT USERS]", sourceDb); var decoRepos = new DecoRepository(sourceDb); decoRepos.Log += Log; decoRepos.DeleteUserSessions(); Log("[DEPLOY SCRIPTS]", sourceDb); var dsr = new DeployScriptsRepository(sourceDb); dsr.Log += Log; dsr.Process(); return; } // Maj toutes les bases sauf la première foreach (var arg in args) { var targetDb = dbList.First(d => d.name == arg); if (targetDb.name == args.First()) { continue; } Log("[START SYNC]", targetDb); // Déconnecte tout le monde Log("[DISCONNECT USERS]", targetDb); var decoRepos = new DecoRepository(targetDb); decoRepos.Log += Log; if (!decoRepos.DeleteUserSessions()) { continue; } Log("[DEPLOY SCRIPTS]", targetDb); var dsr = new DeployScriptsRepository(targetDb); dsr.Log += Log; dsr.Process(); Log("[MAJ COMPTA]", targetDb); var cptr = new ComptaRepository(targetDb, sourceDb); cptr.Log += Log; cptr.MajAll(); Log("[MAJ FOURN]", targetDb); var fr = new Model.FournisseurRepository(targetDb, sourceDb); fr.Log += Log; fr.MajAll(); Log("[MAJ CATALOGUE]", targetDb); var catr = new CatalogueRepository(targetDb, sourceDb); catr.Log += Log; catr.MajAll(); Log("[MAJ FAMILLE]", targetDb); var famr = new FamilleRepository(targetDb, sourceDb); famr.Log += Log; famr.MajAll(); // TODO résoudre les problèmes d'index entre les bases avant MEP //Log("[MAJ MODELES REGLEMENT]", targetDb); //var mrr = new ModRegRepository(targetDb, sourceDb); //mrr.Log += Log; //mrr.MajAll(); Log("[MAJ GLOSSAIRE]", targetDb); var gr = new GlossaireRepository(targetDb, sourceDb); gr.Log += Log; gr.MajAll(); var ar = new ArticleRepository(targetDb, sourceDb); ar.Log += Log; Log("[MAJ CONDITIONNEMENTS]", targetDb); ar.MajConditionnements(); Log("[MAJ GAMMES]", targetDb); ar.MajGammes(); Log("[MAJ ARTICLES]", targetDb); ar.MajAll(); Log("[DELETE FAMILLES]", targetDb); famr.DeleteFamilles(); Log("DELETE CATALOGUE", targetDb); catr.DeleteCatalogue(); Log("[END SYNC]", targetDb); } } catch (Exception e) { Console.WriteLine(e.ToString()); EventLog.WriteEntry("Application", e.ToString()); } finally { EventLog.WriteEntry("Application", "END SYNC SAGE DB"); } Console.WriteLine("FIN"); Console.Read(); }
public _ExcellentArticle() { _repository = new ArticleRepository(); }
private void WriteFieldValues() { var articles = GetArticlesForExport(_settings.FieldsToExpandSettings); var aliases = _settings.FieldsToExpandSettings.Select(n => n.Alias).ToArray(); var fields = _extensionContents.SelectMany(c => c.Fields).Concat(FieldRepository.GetFullList(_contentId)).ToList(); var ids = articles.AsEnumerable().Select(n => (int)n.Field <decimal>("content_item_id")).ToArray(); var extensionIdsMap = _extensionContents.ToDictionary(c => c.Id, c => articles .AsEnumerable() .Select(n => n.Field <decimal?>(string.Format(FieldNameHeaderTemplate, c.Name, IdentifierFieldName))) .Where(n => n.HasValue) .Select(n => (int)n.Value) .ToArray() ); if (articles.Any()) { var dict = fields .Where(n => n.ExactType == FieldExactTypes.M2MRelation && articles[0].Table.Columns.Contains(n.ContentId == _contentId ? n.Name : string.Format(FieldNameHeaderTemplate, n.Content.Name, n.Name))) .Select(n => new { LinkId = n.LinkId.Value, n.ContentId }) .ToDictionary(n => n.LinkId, m => ArticleRepository.GetLinkedItemsMultiple(m.LinkId, m.ContentId == _contentId ? ids : extensionIdsMap[m.ContentId])); foreach (var article in articles) { _sb.AppendFormat("{0}{1}", article["content_item_id"], _settings.Delimiter); foreach (DataColumn column in article.Table.Columns) { var value = article[column.ColumnName].ToString(); var field = fields.FirstOrDefault(f => f.ContentId == _contentId ? f.Name == column.ColumnName : string.Format(FieldNameHeaderTemplate, f.Content.Name, f.Name) == column.ColumnName); var alias = aliases.FirstOrDefault(n => aliases.Contains(column.ColumnName)); if (!string.IsNullOrEmpty(alias)) { _sb.AppendFormat("{0}{1}", FormatFieldValue(value), _settings.Delimiter); } else if (field != null) { _sb.AppendFormat("{0}{1}", FormatFieldValue(article, value, field, dict), _settings.Delimiter); } else if (_extensionContents.Any(c => string.Format(FieldNameHeaderTemplate, c.Name, IdentifierFieldName) == column.ColumnName)) { _sb.AppendFormat("{0}{1}", string.IsNullOrEmpty(value) ? "NULL" : value, _settings.Delimiter); } } if (!_settings.ExcludeSystemFields) { foreach (var fieldValue in new[] { MultistepActionHelper.DateCultureFormat(article[FieldName.Created].ToString(), CultureInfo.CurrentCulture.Name, _settings.Culture), MultistepActionHelper.DateCultureFormat(article[FieldName.Modified].ToString(), CultureInfo.CurrentCulture.Name, _settings.Culture), article[FieldName.UniqueId].ToString(), "0" }) { _sb.Append(fieldValue); _sb.Append(_settings.Delimiter); } } _sb.Append(_settings.LineSeparator); } } using (var sw = new StreamWriter(_settings.UploadFilePath, true, Encoding.GetEncoding(_settings.Encoding))) { sw.Write(_sb.ToString()); } _processedItemsCount = articles.Count; }
public override MessageResult Remove(int parentId, int id) => ArticleRepository.IsAnyAggregatedFields(parentId) ? MessageResult.Error(ArticleStrings.OperationIsNotAllowedForAggregated) : base.Remove(parentId, id);
public ArticleService() { _articleRepository = new ArticleRepository(); _newspaperRepository = new NewspaperRepository(); _authorArticleRepository = new AuthorArticleRepository(); }
public override MessageResult MultipleRemove(int parentId, IEnumerable <int> ids) => ArticleRepository.IsAnyAggregatedFields(parentId) ? MessageResult.Error(ArticleStrings.OperationIsNotAllowedForAggregated) : base.MultipleRemove(parentId, ids);
public ArticleService(ArticleRepository articleRepo) { _articleRepo = articleRepo; }
public JsonResult Comment(int articleId, int commentId, string content) { ArticleRepository articleRepository = new ArticleRepository(); CommentRepository commentRepository = new CommentRepository(); Article article = new Article(); Comment comment = new Comment(); article = articleRepository.GetById(articleId); if (commentId == 0) { comment.ArticleID = articleId; comment.Content = content; comment.DateCreated = DateTime.Now; comment.UserID = AuthenticationManager.LoggedUser.Id; string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString(); int start = type.LastIndexOf(".") + 1; int positions = type.Length - start; type = type.Substring(start, positions); comment.UserType = type; } else { comment = commentRepository.GetById(commentId); comment.Content = content; comment.DateCreated = DateTime.Now; string type = AuthenticationManager.LoggedUser.GetType().BaseType.ToString(); int start = type.LastIndexOf(".") + 1; int positions = type.Length - start; type = type.Substring(start, positions); comment.UserType = type; } commentRepository.Save(comment); string comentator = AuthenticationManager.LoggedUser.FirstName + " " + AuthenticationManager.LoggedUser.LastName; SelectListItem commentContent = new SelectListItem() { Text = comment.Content, Value = comentator }; return Json(commentContent, JsonRequestBehavior.AllowGet); }