示例#1
0
        public IActionResult Wizard(int?id)
        {
            var model = new CompanyViewModel();

            if (id.HasValue && id > 0)
            {
                var company = _companiesService.GetById(id.Value);

                if (company.UserId == _currentUser.UserId)
                {
                    model.Id      = company.Id;
                    model.Name    = company.Name;
                    model.Url     = company.Url;
                    model.LogoUrl = model.LogoUrl;
                    model.UserId  = _currentUser.UserId;
                    model.Email   = company.Email;
                }
                else
                {
                    return(RedirectToAction("Index", "UserProfile").WithError("No tienes permiso para editar esta Compañia"));
                }
            }

            return(View(model));
        }
        private ApiResult CheckPermission(User u, MembersFilterDto filter, string companyRegion, string prevRegion)
        {
            var regionResult = CheckRegion(u, companyRegion, prevRegion);

            if (filter == null || regionResult.Status != 0)
            {
                return(regionResult);
            }
            if (u == null)
            {
                return(ActionStatusMessage.UserMessage.NotExist);
            }
            var targetCompanies = filter.Companies;

            foreach (var targetCompany in targetCompanies)
            {
                var permit            = userActionServices.Permission(u?.Application?.Permission, DictionaryAllPermission.Apply.AuditStream, Operation.Create, u.Id, targetCompany);
                var targetCompanyItem = companiesService.GetById(targetCompany);
                if (!targetCompany.StartsWith(companyRegion))
                {
                    return(new ApiResult(ActionStatusMessage.Account.Auth.Invalid.Default.Status, $"包含的单位{targetCompanyItem?.Name}({targetCompany})的越权"));
                }
                if (!permit)
                {
                    return(new ApiResult(ActionStatusMessage.Account.Auth.Invalid.Default.Status, $"不具有{targetCompanyItem?.Name}({targetCompany})的权限"));
                }
            }
            return(ActionStatusMessage.Success);
        }
        public static ApplyAuditStreamNodeActionVDto ToNodeVDtoModel(this ApplyAuditStreamNodeActionDto model, IUsersService userServices, ICompaniesService companiesService, ApplyAuditStreamNodeActionVDto raw = null)
        {
            if (model == null)
            {
                return(null);
            }
            if (raw == null)
            {
                raw = new ApplyAuditStreamNodeActionVDto();
            }

            raw.Id                = model.Id;
            raw.AuditMembers      = model.AuditMembers?.Select(m => userServices.GetById(m)?.ToSummaryDto());
            raw.AuditMembersCount = model.AuditMembersCount;
            raw.Companies         = model.Companies?.Select(c => companiesService.GetById(c)?.ToDto());
            raw.CompanyCodeLength = model.CompanyCodeLength;
            raw.CompanyRefer      = model.CompanyRefer;
            raw.CompanyTags       = model.CompanyTags;
            raw.Create            = model.Create;
            raw.Description       = model.Description;
            raw.Duties            = model.Duties?.Select(d => companiesService.GetDuties(d)?.ToDto());
            raw.DutyIsMajor       = model.DutyIsMajor;
            raw.DutyTags          = model.DutyTags;
            raw.Name              = model.Name;
            raw.RegionOnCompany   = model.CompanyRegion;
            return(raw);
        }
示例#4
0
 public static ApplyAuditStreamSolutionRuleVDto ToSolutionRuleVDtoModel(this ApplyAuditStreamSolutionRuleDto model, IUsersService usersService, ICompaniesService companiesService)
 {
     if (model == null)
     {
         return(null);
     }
     return(new ApplyAuditStreamSolutionRuleVDto()
     {
         Id = model.Id,
         AuditMembers = model.AuditMembers?.Select(m => usersService.GetById(m)?.ToSummaryDto()),
         AuditMembersCount = model.AuditMembersCount,
         Companies = model.Companies?.Select(c => companiesService.GetById(c)?.ToDto()),
         CompanyCodeLength = model.CompanyCodeLength,
         CompanyRefer = model.CompanyRefer,
         CompanyTags = model.CompanyTags,
         Create = model.Create,
         Description = model.Description,
         Duties = model.Duties?.Select(d => companiesService.GetDuties(d)?.ToDto()),
         DutyIsMajor = model.DutyIsMajor,
         DutyTags = model.DutyTags,
         Enable = model.Enable,
         Name = model.Name,
         Priority = model.Priority,
         SolutionName = model.SolutionName,
         RegionOnCompany = model.CompanyRegion
     });
 }
示例#5
0
        public IActionResult Detail(string id)
        {
            var c = _companiesService.GetById(id);

            if (c == null)
            {
                return(new JsonResult(ActionStatusMessage.CompanyMessage.NotExist));
            }
            return(new JsonResult(new EntityViewModel <Company>(c)));
        }
示例#6
0
        public CompanyViewModel Build(int?id = null)
        {
            if (!id.HasValue)
            {
                return(new CompanyViewModel());
            }

            var company = _service.GetById(id.Value);

            if (company == null)
            {
                throw new InvalidOperationException("The company with id {0} was not found".FormatString(id));                  //TODO - 404 error
            }
            return(new CompanyViewModel
            {
                Id = company.Id,
                CompanyName = company.Name
            });
        }
        public async Task <IActionResult> GetById(long id)
        {
            var model = await _service.GetById(id);

            return(Ok(model));
        }