Ejemplo n.º 1
0
        public void Put(int id, MixERP.Net.Entities.CRM.OpportunityStage item)
        {
            if (item == null || id <= 0)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            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.Update("crm.opportunity_stages", "opportunity_stage_id", item);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Ejemplo n.º 2
0
        public bool Post(MixERP.Net.Entities.CRM.OpportunityStage item)
        {
            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            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.Insert(item);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(true);
        }