Ejemplo n.º 1
0
        public override void PreInitialize()
        {
            // Pages
            Configuration.Authorization.Providers.Add <AbpLearningAuthorizationProvider>();

            // 云书单权限
            Configuration.Authorization.Providers.Add <CloudBookListAuthorizationProvider>();

            // File
            Configuration.Authorization.Providers.Add <FileAuthorizationProvider>();

            // 自定义类型映射
            Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration =>
            {
                BookMapper.CreateMappings(configuration);

                BookListMapper.CreateMappings(configuration);

                RoleMapper.CreateMappings(configuration);

                PermissionMapper.CreateMappings(configuration);

                UserMapper.CreateMappings(configuration);

                OrganizationMapper.CreateMappings(configuration);
            });
        }
Ejemplo n.º 2
0
        public async Task <bool> AddOrganizationAsync(BLLOrganizationDTO organization)
        {
            await Uow.Organizations.AddAsync(OrganizationMapper.FromBLL(organization));

            await Uow.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 3
0
        public ActionResult Company(OrgRegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }

            AppUser user = new AppUser
            {
                UserName          = model.Email,
                Email             = model.Email,
                LockoutEnabled    = true,
                LockoutEndDateUtc = DateTime.Now.AddHours(7)
            };



            IdentityResult identResult = UserManager.Create(user, model.Password);

            if (!identResult.Succeeded)
            {
                AddErrorsFromResult(identResult);
                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }
            model.SmallPathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 40, 40);
            model.LargePathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 135, 135);
            model.OwnerId        = user.Id;
            UserManager.AddToRole(user.Id, RoleConstant.RoleCompany);
            orgService.Edit(OrganizationMapper.ToEntity(model));
            profileService.Edit(UserProfileMapper.ToEntity(model));



#if _DEBUG
            SignInManager.SignIn(user, model.RememberMe, false);
            return(Redirect("~/"));
#endif

#if _RELEASE
            string token = UserManager.GenerateEmailConfirmationToken(user.Id);
            SendEmail(new EmailVerify
            {
                CallbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }),
                cid         = Guid.NewGuid().ToString(),
                UserName    = user.UserName
            }, user.Id);

            return(View("TwoFactorMessage"));
#endif
        }
Ejemplo n.º 4
0
        public async Task <BLLOrganizationDTO> GetOrganizationMinAsync(int organizationId)
        {
            var organization = await Uow.Organizations.FindMinDTOAsync(organizationId);

            if (organization == null)
            {
                return(null);
            }
            return(OrganizationMapper.FromDAL2(organization));
        }
Ejemplo n.º 5
0
        public async Task <BLLOrganizationDTO> GetOrganizationWithCategoriesAsync(int organizationId)
        {
            var organization = await Uow.Organizations.FindWithCategoriesAsync(organizationId);

            if (organization?.Categories == null || organization.Categories.Count == 0)
            {
                return(null);
            }

            return(OrganizationMapper.FromDAL4(organization));
        }
Ejemplo n.º 6
0
        public async Task <DALOrganizationDTO> FindMinDTOAsync(int id)
        {
            var organization = await RepoDbSet.FindAsync(id);

            if (organization == null || organization.IsDeleted)
            {
                return(null);
            }

            return(OrganizationMapper.FromDomain2(organization));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(int id = 0)
        {
            OrganizationViewModel model = new OrganizationViewModel();

            if (id > 0)
            {
                var entity = orgService.GetById(id);
                model = OrganizationMapper.ToViewModel(entity);
            }


            model.IsInRole           = User.IsInRole;
            ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
            return(View(model));
        }
Ejemplo n.º 8
0
        public async Task <DALOrganizationDTO> FindWithCategoriesAsync(int id)
        {
            var organization = await RepoDbSet
                               .Include(o => o.Categories)
                               .ThenInclude(category => category.CategoryName)
                               .ThenInclude(name => name.Translations)
                               .FirstOrDefaultAsync(o => o.IsDeleted == false && o.Id == id);

            if (organization == null)
            {
                return(null);
            }

            return(OrganizationMapper.FromDomain3(organization));
        }
Ejemplo n.º 9
0
        public async Task <BLLOrganizationDTO> GetOrganizationAllDTOAsync(int id)
        {
            var organization = await Uow.Organizations.FindMinDTOAsync(id);

            if (organization == null)
            {
                return(null);
            }

            var categories = await Uow.Categories.AllAsync(organizationId : id);

            var products = await Uow.Products.AllAsync(organizationId : id);

            var changes = await Uow.Changes.AllAsync(organizationId : id);

            return(OrganizationMapper.FromDAL3(organization, categories, products, changes));
        }
Ejemplo n.º 10
0
        public ActionResult GetOrganization(OrgFilterFiewModel model)
        {
            model.InitSortingData();
            var list = GetOrganizationList(model);
            var res  = list.Select(x => OrganizationMapper.ToViewModel(x));

            var result = res.Select(x => new
            {
                Id               = x.Id,
                Name             = x.Name,
                SmallPathImage   = x.SmallPathImage,
                DateReg          = x.DateCreate.GetFormatDate(),
                ShortDescription = x.ShortDescription,
                Classifier       = x.Classifier.Name,
            });

            return(Json(new { data = result, draw = model.draw, recordsTotal = model.CountTotal, recordsFiltered = model.CountTotal }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public IActionResult Edit(Guid id)
        {
            var organizationUid = id;

            if (organizationUid.IsEmptyGuid())
            {
                organizationUid = CurrentUser.OrganizationUid;
            }

            var request  = new OrganizationReadRequest(CurrentUser.Id, organizationUid);
            var response = OrganizationService.GetOrganization(request);

            if (response.Status.IsNotSuccess)
            {
                return(RedirectToAccessDenied());
            }

            var model = OrganizationMapper.MapOrganizationEditModel(response.Item);

            return(View(model));
        }
Ejemplo n.º 12
0
        public ActionResult Edit(OrganizationViewModel model)
        {
            model.IsInRole = User.IsInRole;

            if (ModelState.IsValid)
            {
                if (model.ImgFile != null)
                {
                    DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar);

                    var entity = orgService.GetById(model.Id);
                    if (entity != null)
                    {
                        if (entity.SmallPathImage != null)
                        {
                            DirectoryTools.DeleteFile(HttpContext, entity.SmallPathImage);
                        }

                        if (entity.LargePathImage != null)
                        {
                            DirectoryTools.DeleteFile(HttpContext, entity.LargePathImage);
                        }
                    }

                    model.SmallPathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 50, 50);
                    model.LargePathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 250, 250);
                }

                var result = orgService.Edit(OrganizationMapper.ToEntity(model));
                if (result != null)
                {
                    return(RedirectToAction("Index", "Organization"));
                }
            }
            ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
            return(View(model));
        }
Ejemplo n.º 13
0
 public OrganizationService(IOrganizationRepository repos)
 {
     Repository = repos;
     OrganizationMapper.Map();
 }
Ejemplo n.º 14
0
        public IOrganization GetOrganization(Guid id)
        {
            var mapper = new OrganizationMapper();

            return(mapper.Map(queryService.GetOrganization(id)));
        }
Ejemplo n.º 15
0
        public IEnumerable <IOrganization> GetOrganizations()
        {
            var mapper = new OrganizationMapper();

            return(mapper.Map(queryService.GetOrganizations()));
        }
Ejemplo n.º 16
0
 public async Task AddAsync(DALOrganizationDTO organizationDTO)
 {
     await RepoDbSet.AddAsync(OrganizationMapper.FromDAL(organizationDTO));
 }
Ejemplo n.º 17
0
 public OrganizationInfo(IOrganizationRepository repository)
 {
     this.Repository = repository;
     OrganizationMapper.Map();
 }