public async Task <IActionResult> PutAspNetRole(long id, AspNetRoleModel model)
        {
            var result = Check(id == model.Id, BadRequest).OkNull() ?? Check(Operation.Update).OkNull() ?? CheckIfMatch(model.Id);

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

            var entity = await DB_TABLE.FirstOrDefaultAsync(e => e.Id == model.Id);

            entity.Name             = model.Name;
            entity.NormalizedName   = model.Name.ToUpper();
            entity.ConcurrencyStamp = Guid.NewGuid().ToString();
            entity.PermissibleLevel = model.PermissibleLevel;

            DB.Entry(entity).State = EntityState.Modified;
            try { await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DB_TABLE.Any(e => e.Id == id))
                                                                                        {
                                                                                            return(NotFound());
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            throw;
                                                                                        } }

            Log(DB_TABLE.GetName(), Operation.Update, null, model);

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteJob(long id)
        {
            var entity = await DB_TABLE.Include(e => e.JobContacts).Include(e => e.JobScripts).Include(e => e.InboxScripts).FirstOrDefaultAsync(e => e.Id == id);

            var campaign = entity?.Campaign;

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(Operation.Delete, campaign.Id);

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

            {
                DB.RemoveRange(entity.JobContacts);
                DB.RemoveRange(entity.JobScripts);
                DB.RemoveRange(entity.InboxScripts);
                DB_TABLE.Remove(entity);
            }

            await DB.SaveChangesAsync();

            var operation_Id = Guid.NewGuid();

            {
                Log(DB_TABLE.GetName(), Operation.Delete, operation_Id, campaign.Id, GetModel(entity));
                Get <JobContactsController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.JobContacts);
                Get <JobScriptsController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.JobScripts);
                Get <InboxScriptsController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.InboxScripts);
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutCompany(long id, CompanyModel model)
        {
            var result = Check(id == model.Id, BadRequest).OkNull() ?? Check(Operation.Update).OkNull() ?? CheckIfMatch(model.Id);

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

            var entity = GetEntity(model);

            DB.Entry(entity).State = EntityState.Modified;
            try { await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DB_TABLE.Any(e => e.Id == id))
                                                                                        {
                                                                                            return(NotFound());
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            throw;
                                                                                        } }

            Log(DB_TABLE.GetName(), Operation.Update, null, model);

            return(NoContent());
        }
        public async Task <IActionResult> PutCampaign(long id, CampaignModel model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            var campaign_Id = model.Id;

            var result = Check(model.Company_Id == COMPANY_ID, Forbidden).OkNull() ?? Check(Operation.Update, campaign_Id).OkNull() ?? CheckIfMatch(model.Id);

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

            var entity = GetEntity(model);

            DB.Entry(entity).State = EntityState.Modified;
            try { await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DB_TABLE.Any(e => e.Id == id))
                                                                                        {
                                                                                            return(NotFound());
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            throw;
                                                                                        } }

            Log(DB_TABLE.GetName(), Operation.Update, campaign_Id, model);

            return(NoContent());
        }
        public async Task <IActionResult> DeleteCampaign(long id)
        {
            var entity = await DB_TABLE
                         .Include(e => e.ContactGroups) // stop
                         .Include(e => e.Jobs)          // stop
                         .Include(e => e.Leads)         // stop
                         .Include(e => e.Scripts)       // stop
                         .Include(e => e.Gateways)
                         .ThenInclude(e => e.GatewayStreams)
                         .Include(e => e.ContactProperties)
                         .Include(e => e.LeadProperties)
                         .Include(e => e.UserRoles)
                         .FirstOrDefaultAsync(e => e.Id == id);

            if (entity == null)
            {
                return(NotFound());
            }

            var campaign_Id = id;

            var result =
                Check(entity.Company_Id == COMPANY_ID, Forbidden).OkNull() ??
                Check(Operation.Delete, campaign_Id).OkNull() ??
                Check(entity.ContactGroups.Count == 0, Forbidden, string.Format(Strings.Cascade_Message, Strings.Campaign_Entity, Strings.ContactGroup_List)).OkNull() ??
                Check(entity.Jobs.Count == 0, Forbidden, string.Format(Strings.Cascade_Message, Strings.Campaign_Entity, Strings.Job_List)).OkNull() ??
                Check(entity.Leads.Count == 0, Forbidden, string.Format(Strings.Cascade_Message, Strings.Campaign_Entity, Strings.Lead_List)).OkNull() ??
                Check(entity.Scripts.Count == 0, Forbidden, string.Format(Strings.Cascade_Message, Strings.Campaign_Entity, Strings.Script_List));

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

            {
                DB.RemoveRange(entity.Gateways.SelectMany(e => e.GatewayStreams));
                DB.RemoveRange(entity.Gateways);
                DB.RemoveRange(entity.ContactProperties);
                DB.RemoveRange(entity.LeadProperties);
                DB.RemoveRange(entity.UserRoles);
                DB_TABLE.Remove(entity);
            }

            await DB.SaveChangesAsync();

            var operation_Id = Guid.NewGuid();

            {
                Log(DB_TABLE.GetName(), Operation.Delete, operation_Id, campaign_Id, GetModel(entity));
                Get <GatewayStreamsController>().Log(Operation.Delete, operation_Id, campaign_Id, entity.Gateways.SelectMany(e => e.GatewayStreams));
                Get <GatewaysController>().Log(Operation.Delete, operation_Id, campaign_Id, entity.Gateways);
                Get <ContactPropertiesController>().Log(Operation.Delete, operation_Id, campaign_Id, entity.ContactProperties);
                Get <LeadPropertiesController>().Log(Operation.Delete, operation_Id, campaign_Id, entity.LeadProperties);
                Get <AspNetUserRolesController>().Log(Operation.Delete, operation_Id, campaign_Id, entity.UserRoles);
            }

            Log(DB_TABLE.GetName(), Operation.Delete, campaign_Id, GetModel(entity));

            return(NoContent());
        }
        public async Task<IActionResult> DeleteScriptElement(long id)
        {
            var entity = await DB_TABLE.Include(e => e.ScriptConditions).Include(e => e.ScriptInputParameters).Include(e => e.ScriptOutputParameters).FirstOrDefaultAsync(e => e.Id == id);
            var campaign = entity?.Script?.Campaign;

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(DB.Scripts, Operation.Update, campaign.Id);
            if (result.Fail()) return result;

            {
                DB.RemoveRange(entity.ScriptConditions);
                DB.RemoveRange(entity.ScriptInputParameters);
                DB.RemoveRange(entity.ScriptOutputParameters);
                DB_TABLE.Remove(entity);
            }

            await DB.SaveChangesAsync();

            var operation_Id = Guid.NewGuid();
            {
                Log(DB_TABLE.GetName(), Operation.Delete, operation_Id, campaign.Id, GetModel(entity));
                Get<ScriptConditionsController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.ScriptConditions);
                Get<ScriptInputParametersController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.ScriptInputParameters);
                Get<ScriptOutputParametersController>().Log(Operation.Delete, operation_Id, campaign.Id, entity.ScriptOutputParameters);
            }

            return NoContent();
        }
Esempio n. 7
0
        public async Task <IActionResult> DeleteAspNetUser(long id)
        {
            var entity = await DB_TABLE.FindAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }

            var result = Check(Operation.Delete);

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

            var identityResult = await UserManager.SetLockoutEndDateAsync(entity, DateTimeOffset.MaxValue);

            if (identityResult.Succeeded)
            {
                identityResult = await UserManager.UpdateSecurityStampAsync(entity);
            }

            if (identityResult.Succeeded)
            {
                Log(DB_TABLE.GetName(), Operation.Delete, null, GetModel(entity));
                return(NoContent());
            }

            return(BadRequest(string.Join(";", identityResult.Errors.Select(e => e.Description))));
        }
Esempio n. 8
0
        public async Task <IActionResult> PutAspNetUser(long id, AspNetUserModel model)
        {
            var result = Check(id == model.Id, BadRequest).OkNull() ?? Check(Operation.Update).OkNull() ?? CheckIfMatch(model.Id);

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

            var entity = await DB_TABLE.FirstOrDefaultAsync(e => e.Id == model.Id);

            entity.Company_Id  = model.Company_Id;
            entity.UserName    = model.UserName;
            entity.Email       = model.Email;
            entity.PhoneNumber = model.PhoneNumber;
            var identityResult = await UserManager.UpdateAsync(entity);

            if (!identityResult.Succeeded)
            {
                return(BadRequest(string.Join(";", identityResult.Errors.Select(e => e.Description))));
            }

            Log(DB_TABLE.GetName(), Operation.Update, null, model);

            return(NoContent());
        }
Esempio n. 9
0
        public async Task <IActionResult> PutJobScript(long id, JobScriptModel model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            var campaign = DB.Jobs.Find(model.Job_Id)?.Campaign;

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(DB.Jobs, Operation.Update, campaign.Id).OkNull() ?? CheckIfMatch(model.Id);

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

            var entity = GetEntity(model);

            DB.Entry(entity).State = EntityState.Modified;
            try { await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DB_TABLE.Any(e => e.Id == id))
                                                                                        {
                                                                                            return(NotFound());
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            throw;
                                                                                        } }

            Log(DB_TABLE.GetName(), Operation.Update, campaign.Id, model);

            return(NoContent());
        }
        public async Task <IActionResult> DeleteAspNetRole(long id)
        {
            var entity = await DB_TABLE.Include(e => e.RolePermissions).Include(e => e.UserRoles).FirstOrDefaultAsync(e => e.Id == id);

            if (entity == null)
            {
                return(NotFound());
            }

            var result = Check(Operation.Delete);

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

            {
                DB.RemoveRange(entity.RolePermissions);
                DB.RemoveRange(entity.UserRoles);
                DB_TABLE.Remove(entity);
            }

            await DB.SaveChangesAsync();

            var operation_Id = Guid.NewGuid();

            {
                Log(DB_TABLE.GetName(), Operation.Delete, operation_Id, null, GetModel(entity));
                Get <AspNetRolePermissionsController>().Log(Operation.Delete, operation_Id, null, entity.RolePermissions);
                Get <AspNetUserRolesController>().Log(Operation.Delete, operation_Id, null, entity.UserRoles);
            }

            return(NoContent());
        }
        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();
        }
        public async Task <ActionResult <IEnumerable <AspNetRoleModel> > > GetAspNetRoles()
        {
            var result = Check(Operation.Read);

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

            return(await DB_TABLE
                   .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());
        }
Esempio n. 15
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());
        }
Esempio n. 16
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());
        }
        public async Task<ActionResult<ScriptElementModel>> GetScriptElement(long id)
        {
            var result = Check(DB.Scripts, Operation.Read);
            if (result.Fail()) return result;

            var entity = await DB_TABLE
                .Join(AllowedIds(Operation.Read), o => o.Script.Campaign_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);
        }
Esempio n. 18
0
        public async Task <IActionResult> DeleteCompany(long id)
        {
            var entity = await DB_TABLE
                         .Include(e => e.Campaigns) // stop
                         .Include(e => e.CompanyExpenses)
                         .Include(e => e.CompanyIncomes)
                         .Include(e => e.Users)
                         .ThenInclude(e => e.UserLogs)
                         .Include(e => e.Users)
                         .ThenInclude(e => e.UserRoles)
                         .FirstOrDefaultAsync(e => e.Id == id);

            if (entity == null)
            {
                return(NotFound());
            }

            var result = Check(Operation.Delete).OkNull() ??
                         Check(entity.Campaigns.Count == 0, Forbidden, string.Format(Strings.Cascade_Message, Strings.Company_Entity, Strings.Campaign_List));

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

            {
                DB.RemoveRange(entity.Users.SelectMany(e => e.UserLogs));
                DB.RemoveRange(entity.Users.SelectMany(e => e.UserRoles));
                DB.RemoveRange(entity.Users);
                DB.RemoveRange(entity.CompanyExpenses);
                DB.RemoveRange(entity.CompanyIncomes);
                DB_TABLE.Remove(entity);
            }

            await DB.SaveChangesAsync();

            var operation_Id = Guid.NewGuid();

            {
                Log(DB_TABLE.GetName(), Operation.Delete, null, GetModel(entity));
                Get <AspNetUserLogsController>().Log(Operation.Delete, operation_Id, null, entity.Users.SelectMany(e => e.UserLogs));
                Get <AspNetUserRolesController>().Log(Operation.Delete, operation_Id, null, entity.Users.SelectMany(e => e.UserRoles));
                Get <AspNetUsersController>().Log(Operation.Delete, operation_Id, null, entity.Users);
                Get <CompanyExpensesController>().Log(Operation.Delete, operation_Id, null, entity.CompanyExpenses);
                Get <CompanyIncomesController>().Log(Operation.Delete, operation_Id, null, entity.CompanyIncomes);
            }

            return(NoContent());
        }
Esempio n. 19
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());
        }
        public async Task<ActionResult<ScriptElementModel>> PostScriptElement(ScriptElementCreateModel model)
        {
            var campaign = DB.Scripts.Find(model.Script_Id)?.Campaign;

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(DB.Scripts, Operation.Update);
            if (result.Fail()) return result;

            var entity = GetEntity(model);

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Create, campaign.Id, GetModel(entity));

            return CreatedAtAction(nameof(GetScriptElement), new { id = entity.Id }, GetModel(entity));
        }
Esempio n. 22
0
        public async Task <ActionResult <CompanyModel> > PostCompany(CompanyCreateModel model)
        {
            var result = Check(Operation.Create);

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

            var entity = new Company
            {
                Name = model.Name
            };

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            var user = new AspNetUser {
                UserName = model.Name, Email = model.Email, Company_Id = entity.Id, Level = AspNetUserLevel.Company
            };
            var identityResult = await UserManager.CreateAsync(user, model.Password);

            if (identityResult.Succeeded)
            {
                await SignInManager.SignInAsync(user, isPersistent : false);

                if (User.Identity is ClaimsIdentity)
                {
                    ((ClaimsIdentity)User.Identity).AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString(), ClaimValueTypes.Integer64));

                    Log(DB_TABLE.GetName(), Operation.Create, null, GetModel(entity));
                    Log(DB.Users.GetName(), Operation.Create, null, model);
                }

                return(CreatedAtAction(nameof(GetCompany), new { id = entity.Id }, GetModel(entity)));
            }

            if ((entity = await DB_TABLE.FindAsync(entity.Id)) != null)
            {
                DB_TABLE.Remove(entity);
                await DB.SaveChangesAsync();
            }

            return(BadRequest(string.Join(";", identityResult.Errors.Select(e => e.Description))));
        }
        public async Task <ActionResult <AspNetUserRoleModel> > PostAspNetUserRole(AspNetUserRoleCreateModel model)
        {
            var result = Check(Operation.Create);

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

            var entity = GetEntity(model);

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Create, null, GetModel(entity));

            return(CreatedAtAction(nameof(GetAspNetUserRole), new { id = entity.Id }, GetModel(entity)));
        }
Esempio n. 24
0
        public async Task <ActionResult <CompanyIncomeModel> > PostCompanyIncome(CompanyIncomeCreateModel model)
        {
            var result = Check(model.Company_Id == COMPANY_ID, Forbidden).OkNull() ?? Check(Operation.Create);

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

            var entity = GetEntity(model);

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Create, null, GetModel(entity));

            return(CreatedAtAction(nameof(GetCompanyIncome), new { id = entity.Id }, GetModel(entity)));
        }
        public async Task <ActionResult <TariffConditionModel> > PostTariffCondition(TariffConditionCreateModel model)
        {
            var result = Check(DB.Tariffs, Operation.Update);

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

            var entity = GetEntity(model);

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Create, null, GetModel(entity));

            return(CreatedAtAction(nameof(GetTariffCondition), new { id = entity.Id }, GetModel(entity)));
        }
Esempio n. 26
0
        public async Task <IActionResult> DeleteJobScript(long id)
        {
            var entity = await DB_TABLE.FindAsync(id);

            var campaign = entity?.Job?.Campaign;

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(DB.Jobs, Operation.Update, campaign.Id);

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

            DB_TABLE.Remove(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Delete, campaign.Id, GetModel(entity));

            return(NoContent());
        }
        public async Task <ActionResult <AspNetUserLogModel> > GetAspNetUserLog(long id)
        {
            var result = Check(Operation.Read);

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

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

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

            return(GetModel(entity));
        }
Esempio n. 28
0
        public async Task <ActionResult <LeadPropertyModel> > PostLeadProperty(LeadPropertyCreateModel model)
        {
            var campaign = DB.Campaigns.Find(model.Campaign_Id);

            var result = Check(campaign is Campaign, NotFound).OkNull() ?? Check(DB.Campaigns, Operation.Update);

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

            var entity = GetEntity(model);

            DB_TABLE.Add(entity);
            await DB.SaveChangesAsync();

            Log(DB_TABLE.GetName(), Operation.Create, campaign.Id, GetModel(entity));

            return(CreatedAtAction(nameof(GetLeadProperty), new { id = entity.Id }, GetModel(entity)));
        }
Esempio n. 29
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));
        }
Esempio n. 30
0
        public async Task <ActionResult <LeadPropertyModel> > GetLeadProperty(long id)
        {
            var result = Check(DB.Campaigns, Operation.Read);

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

            var entity = await DB_TABLE
                         .Join(AllowedIds(Operation.Read), o => o.Campaign_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));
        }