public HttpResponseMessage Put(afs_authority put_afs_authority) { try { using (var context = new SAPContext()) { var existing = context.afs_authority.Where(t => t.USER_ID == put_afs_authority.USER_ID).FirstOrDefault(); if (existing == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "afs_authority not found")); } else { context.Entry(existing).State = EntityState.Modified; } existing.SALE_FLAG = put_afs_authority.SALE_FLAG; existing.AFTERSALE_FLAG = put_afs_authority.AFTERSALE_FLAG; existing.PURCHASE_FLAG = put_afs_authority.PURCHASE_FLAG; context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, put_afs_authority)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Post(afs_authority post_afs_authority) { try { using (var context = new SAPContext()) { afs_authority data = new afs_authority(); data.USER_ID = post_afs_authority.USER_ID; data.SALE_FLAG = post_afs_authority.SALE_FLAG; data.AFTERSALE_FLAG = post_afs_authority.AFTERSALE_FLAG; data.PURCHASE_FLAG = post_afs_authority.PURCHASE_FLAG; context.afs_authority.Add(data); context.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.InnerException.Message)); } }