public bool Post(MixERP.Net.Entities.CRM.LeadSource item) { if (item == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.LeadSource), new HttpGetAttribute()); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Insert(item); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return(true); }
public void Delete(long id) { if (id <= 0) { return; } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "DELETE"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Delete("core.accounts", "account_id", null, id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public void Delete(int id) { if (id <= 0) { return; } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.OpportunityStage), new HttpGetAttribute()); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Delete("crm.opportunity_stages", "opportunity_stage_id", null, id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public void Put(int id, MixERP.Net.Entities.CRM.LeadStatus item) { if (item == null || id <= 0) { throw new HttpResponseException(HttpStatusCode.BadRequest); } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.LeadStatus), new HttpGetAttribute()); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Update("crm.lead_statuses", "lead_status_id", item); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public MixERP.Net.Entities.Core.Account GetSingle(long id) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "GET"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return db.FirstOrDefault<MixERP.Net.Entities.Core.Account>("SELECT * FROM core.accounts WHERE account_id=@0", id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public IEnumerable<MixERP.Net.Entities.Core.Account> GetPagedResult(long page=1) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "GET"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return db.Page<MixERP.Net.Entities.Core.Account>(page, 10, "SELECT * FROM core.accounts ORDER BY account_id").Items; } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public MixERP.Net.Entities.CRM.LeadSource GetSingle(int id) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.LeadSource), new HttpGetAttribute()); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return(db.FirstOrDefault <MixERP.Net.Entities.CRM.LeadSource>("SELECT * FROM crm.lead_sources WHERE lead_source_id=@0", id)); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public IEnumerable <MixERP.Net.Entities.CRM.OpportunityStage> GetPagedResult(long page = 1) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.OpportunityStage), new HttpGetAttribute()); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return(db.Page <MixERP.Net.Entities.CRM.OpportunityStage>(page, 10, "SELECT * FROM crm.opportunity_stages ORDER BY opportunity_stage_id").Items); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public void Delete(string id) { if (string.IsNullOrWhiteSpace(id)) { return; } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.TaxRateType), "DELETE"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Delete("core.tax_rate_types", "tax_rate_type_code", null, id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public void Put(int id, MixERP.Net.Entities.Core.TaxMaster item) { if (item == null || id <= 0) { throw new HttpResponseException(HttpStatusCode.BadRequest); } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.TaxMaster), "PUT"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Update("core.tax_master", "tax_master_id", item); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public bool Post(MixERP.Net.Entities.Core.TaxMaster item) { if (item == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.TaxMaster), "POST"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Insert(item); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return true; }
public void Put(string id, MixERP.Net.Entities.Core.TaxBaseAmountType item) { if (item == null || string.IsNullOrWhiteSpace(id)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.TaxBaseAmountType), "PUT"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { db.Update("core.tax_base_amount_types", "tax_base_amount_type_code", item); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public MixERP.Net.Entities.Core.SalesTaxExemptDetail GetSingle(int id) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.SalesTaxExemptDetail), "GET"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return db.FirstOrDefault<MixERP.Net.Entities.Core.SalesTaxExemptDetail>("SELECT * FROM core.sales_tax_exempt_details WHERE sales_tax_exempt_detail_id=@0", id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public MixERP.Net.Entities.CRM.OpportunityStage GetSingle(int id) { ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.CRM.OpportunityStage), "GET"); policy.Authorize(); if (!policy.IsAuthorized) { throw new HttpResponseException(HttpStatusCode.Forbidden); } try { using (Database db = new Database(Factory.GetConnectionString(), "Npgsql")) { return db.FirstOrDefault<MixERP.Net.Entities.CRM.OpportunityStage>("SELECT * FROM crm.opportunity_stages WHERE opportunity_stage_id=@0", id); } } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }