private bool IndexEBook(BookViewModel bookViewModel, string path) { bool success; Document document = null; string language = LanguageService.Get(bookViewModel.LanguageId).Name; IndexerType type = AnalyzerService.GetIndexerType(language); BookDomainModelBuilder builder = BuilderResolverService.Get <BookDomainModelBuilder, BookViewModel>(bookViewModel); Constructor.ConstructDomainModelData(builder); BookData book = builder.GetDataModel(); try { document = DocumentHandler.GetDocument(book, path); if (book.Id != 0) { EBookIndexer.DeleteById(book.Id.ToString(), type); } EBookIndexer.Add(document, type); success = true; } catch (Exception e) { success = false; } return(success); }
public BorrowResult BorrowBook(RelationUserBookCopyViewModel viewModel, UserSessionObject user) { var result = new BorrowResult(); viewModel.DateOfIssue = DateTime.Now; viewModel.DateDueForReturn = DateTime.Now.AddDays(14); RelationUserBookCopyDomainModelBuilder builder = BuilderResolverService.Get <RelationUserBookCopyDomainModelBuilder, RelationUserBookCopyViewModel>(viewModel); Constructor.ConstructDomainModelData(builder); RelationUserBookCopyData domainModel = builder.GetDataModel(); if (viewModel.Id == 0) { domainModel.RefUserCreatedBy = user.UserId; } int loanId = RelationUserBookCopyRepository.SaveData(domainModel); if (loanId != 0) { var saveResult = UpdateCopyAndBook(domainModel.BookCopyId, user); if (saveResult.Success) { string username = UserService.Get(domainModel.UserId).Username; result = new BorrowResult(loanId, domainModel.BookCopyId, username); } } return(result); }
public RoleViewModel GetRoleFor(int userId) { var roleId = UserService.Get(userId).RoleId; var role = RoleRepository.GetDataById(roleId); RoleViewModelBuilder builder = BuilderResolverService.Get <RoleViewModelBuilder, RoleData>(role); Constructor.ConstructViewModelData(builder); return(builder.GetViewModel()); }
private List <PermissionViewModel> ConvertDataToViewModels(List <PermissionData> domainModels) { var viewModels = new List <PermissionViewModel>(); foreach (var item in domainModels) { PermissionViewModelBuilder builder = BuilderResolverService.Get <PermissionViewModelBuilder, PermissionData>(item); Constructor.ConstructViewModelData(builder); viewModels.Add(builder.GetViewModel()); } return(viewModels); }
private List <RelationUserBookCopyViewModel> ConvertToViewModels(List <RelationUserBookCopyData> domainModels) { var viewModels = new List <RelationUserBookCopyViewModel>(); foreach (var item in domainModels) { RelationUserBookCopyViewModelBuilder builder = BuilderResolverService.Get <RelationUserBookCopyViewModelBuilder, RelationUserBookCopyData>(item); Constructor.ConstructViewModelData(builder); viewModels.Add(builder.GetViewModel()); } return(viewModels); }
public PermissionViewModel Get(int?permissionId) { var viewModel = new PermissionViewModel(); if (permissionId.HasValue) { PermissionData domainModel = PermissionRepository.GetDataById(permissionId.Value); PermissionViewModelBuilder builder = BuilderResolverService.Get <PermissionViewModelBuilder, PermissionData>(domainModel); Constructor.ConstructViewModelData(builder); viewModel = builder.GetViewModel(); } return(viewModel); }
public RoleViewModel Get(int?roleId) { var viewModel = new RoleViewModel(); if (roleId.HasValue) { RoleData domainModel = RoleRepository.GetDataById(roleId.Value); RoleViewModelBuilder builder = BuilderResolverService.Get <RoleViewModelBuilder, RoleData>(domainModel); Constructor.ConstructViewModelData(builder); viewModel = builder.GetViewModel(); } return(viewModel); }