Esempio 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);
            });
        }
        public async Task <bool> AddOrganizationAsync(BLLOrganizationDTO organization)
        {
            await Uow.Organizations.AddAsync(OrganizationMapper.FromBLL(organization));

            await Uow.SaveChangesAsync();

            return(true);
        }
Esempio 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
        }
        public async Task <BLLOrganizationDTO> GetOrganizationMinAsync(int organizationId)
        {
            var organization = await Uow.Organizations.FindMinDTOAsync(organizationId);

            if (organization == null)
            {
                return(null);
            }
            return(OrganizationMapper.FromDAL2(organization));
        }
        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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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));
        }
        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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio n. 13
0
 public OrganizationService(IOrganizationRepository repos)
 {
     Repository = repos;
     OrganizationMapper.Map();
 }
Esempio n. 14
0
        public IOrganization GetOrganization(Guid id)
        {
            var mapper = new OrganizationMapper();

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

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