예제 #1
0
        public HttpResponseMessage Put(int id, [FromBody] LoanEdu loanedu)
        {
            try
            {
                using (TrustyloandbEntities entities = new TrustyloandbEntities())
                {
                    var entity = entities.LoanEdus.FirstOrDefault(e => e.P_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Person with P_Id " + id.ToString() + " Not Found!"));
                    }
                    else
                    {
                        entity.Edu_Tut_Fees        = loanedu.Edu_Tut_Fees;
                        entity.Edu_Living_Expen    = loanedu.Edu_Living_Expen;
                        entity.Edu_Travel_Expen    = loanedu.Edu_Travel_Expen;
                        entity.Edu_Other_Expen     = loanedu.Edu_Other_Expen;
                        entity.Edu_Total_Expen     = loanedu.Edu_Total_Expen;
                        entity.Edu_Own_Inc         = loanedu.Edu_Own_Inc;
                        entity.Edu_Scholar_Inc     = loanedu.Edu_Scholar_Inc;
                        entity.Edu_Other_Inc       = loanedu.Edu_Other_Inc;
                        entity.Edu_Loan_Required   = loanedu.Edu_Loan_Required;
                        entity.Edu_Disburs_Details = loanedu.Edu_Disburs_Details;
                        entity.Edu_Mode            = loanedu.Edu_Mode;
                        entity.Edu_Dd_In_Favour_Of = loanedu.Edu_Dd_In_Favour_Of;
                        entity.Edu_Payable_At_For  = loanedu.Edu_Payable_At_For;
                        entity.Edu_DD_Amount       = loanedu.Edu_DD_Amount;
                        entity.Edu_Tt_Swift_Code   = loanedu.Edu_Tt_Swift_Code;
                        entity.Edu_Rtgs_Neft       = loanedu.Edu_Rtgs_Neft;
                        entity.Edu_University_Ac   = loanedu.Edu_University_Ac;

                        entities.SaveChanges();

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

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