Example #1
0
        public HttpResponseMessage Put(int id, [FromBody] PropGold propGold)
        {
            try
            {
                using (TrustyloandbEntities entities = new TrustyloandbEntities())
                {
                    var entity = entities.PropGolds.FirstOrDefault(e => e.P_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "PropGold with P_Id " + id.ToString() + " Not Found!"));
                    }
                    else
                    {
                        entity.Gpr_Loan_Amount   = propGold.Gpr_Loan_Amount;
                        entity.Gpr_Tenure_Months = propGold.Gpr_Tenure_Months;
                        entity.Gpr_Payment_Date  = propGold.Gpr_Payment_Date;
                        entity.Gpr_Int_Pay_Mode  = propGold.Gpr_Int_Pay_Mode;
                        entity.Gpr_Disburs_Mode  = propGold.Gpr_Disburs_Mode;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #2
0
        public HttpResponseMessage Post([FromBody] PropGold propGold)
        {
            try
            {
                using (TrustyloandbEntities entities = new TrustyloandbEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    entities.PropGolds.Add(propGold);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, propGold);
                    message.Headers.Location = new Uri(Request.RequestUri + propGold.ID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }