public async Task<ActionResult<IEnumerable<ScriptElementModel>>> GetScriptElements([FromQuery(Name = "oid")] long[] script_Id)
        {
            var result = Check(DB.Scripts, Operation.Read);
            if (result.Fail()) return result;

            return await DB_TABLE
                .Where(e => script_Id.Contains(e.Script_Id))
                .Join(AllowedIds(Operation.Read), o => o.Script.Campaign_Id, i => i, (o, i) => o)
                .Select(entity => GetModel(entity))
                .ToListAsync();
        }
Пример #2
0
        public async Task <ActionResult <IEnumerable <CompanyModel> > > GetCompanies()
        {
            var result = Check(Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(e => e.Id == COMPANY_ID)
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
        public async Task <ActionResult <IEnumerable <AspNetUserLogModel> > > GetAspNetUserLogs([FromQuery(Name = "oid")] long[] user_Id)
        {
            var result = Check(Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(entity => user_Id.Contains(entity.UserId))
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
        public async Task <ActionResult <IEnumerable <TariffConditionModel> > > GetTariffConditions([FromQuery(Name = "oid")] long[] tariff_Id)
        {
            var result = Check(DB.Tariffs, Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(entity => tariff_Id.Contains(entity.Tariff_Id))
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
Пример #5
0
        public async Task <ActionResult <IEnumerable <AspNetRolePermissionModel> > > GetAspNetRolePermissions([FromQuery(Name = "oid")] long[] role_Id)
        {
            var result = Check(DB.Roles, Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(entity => role_Id.Contains(entity.RoleId))
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
Пример #6
0
        public async Task <ActionResult <IEnumerable <JobScriptModel> > > GetJobScripts([FromQuery(Name = "oid")] long[] job_Id)
        {
            var result = Check(DB.Jobs, Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(e => job_Id.Contains(e.Job_Id))
                   .Join(AllowedIds(Operation.Read), o => o.Job.Campaign_Id, i => i, (o, i) => o)
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
        public async Task <ActionResult <IEnumerable <CampaignModel> > > GetCampaigns()
        {
            var result = Check(Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            return(await DB_TABLE
                   .Where(e => e.Company_Id == COMPANY_ID)
                   .Join(AllowedIds(Operation.Read), o => o.Id, i => i, (o, i) => o)
                   .Select(entity => GetModel(entity))
                   .ToListAsync());
        }
Пример #8
0
        public async Task <ActionResult <CompanyModel> > GetCompany(long id)
        {
            var result = Check(Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            var entity = await DB_TABLE
                         .Where(e => e.Id == COMPANY_ID)
                         .FirstOrDefaultAsync(e => e.Id == id);

            result = Check(entity != null, NotFound).OkNull() ?? CheckETag(entity.GetHash());
            if (result.Fail())
            {
                return(result);
            }

            return(GetModel(entity));
        }
        public async Task <ActionResult <CampaignModel> > GetCampaign(long id)
        {
            var result = Check(Operation.Read);

            if (result.Fail())
            {
                return(result);
            }

            var entity = await DB_TABLE
                         .Where(e => e.Company_Id == COMPANY_ID)
                         .Join(AllowedIds(Operation.Read), o => o.Id, i => i, (o, i) => o)
                         .FirstOrDefaultAsync(e => e.Id == id);

            result = Check(entity != null, NotFound).OkNull() ?? CheckETag(entity.GetHash());
            if (result.Fail())
            {
                return(result);
            }

            return(GetModel(entity));
        }