Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void Put(int id, MixERP.Net.Entities.CRM.LeadSource item)
        {
            if (item == null || id <= 0)
            {
                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.Update("crm.lead_sources", "lead_source_id", item);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }