Ejemplo n.º 1
0
        public HttpResponseMessage Post([FromBody] Gstin gstin)
        {
            try
            {
                using (loandbEntities entities = new loandbEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    entities.Gstins.Add(gstin);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, gstin);
                    message.Headers.Location = new Uri(Request.RequestUri + gstin.ID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Put(int id, [FromBody] Gstin gstin)
        {
            try
            {
                using (loandbEntities entities = new loandbEntities())
                {
                    var entity = entities.Gstins.FirstOrDefault(e => e.P_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Person with P_Id " + id.ToString() + " Not Found!"));
                    }
                    else
                    {
                        entity.ID              = entity.ID;
                        entity.P_ID            = entity.P_ID;
                        entity.Gst_Reg         = gstin.Gst_Reg;
                        entity.Gst_Exem        = gstin.Gst_Exem;
                        entity.Gst_Exem_Reason = gstin.Gst_Exem_Reason;
                        entity.Gst_Exem_date   = gstin.Gst_Exem_date;
                        entity.Gst_Reg_Date    = gstin.Gst_Reg_Date;
                        entity.Gst_Reg_Type    = gstin.Gst_Reg_Type;
                        entity.Gst_Eco_Zone    = gstin.Gst_Eco_Zone;
                        entity.Gst_default     = gstin.Gst_default;
                        entity.Gstin_Addr      = gstin.Gstin_Addr;
                        entity.Gst_Pin         = gstin.Gst_Pin;
                        entity.Gst_City        = gstin.Gst_City;
                        entity.Gst_State       = gstin.Gst_State;
                        entity.Gst_Country     = gstin.Gst_Country;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }