public ActionResult UpdateOrder(string ICCID) { int orderId = Int32.Parse(Session["orderId"].ToString()); var result = from d in db.SMKTokens where d.Orderid == orderId && d.Card_id != null select d; IAMSession iamsession = new IAMSession(); DbStock stock = crm.GetStock(ICCID); iamsession.SimOrderId = orderId; iamsession.ICCID = ICCID; iamsession.SessionId = result.FirstOrDefault().Token; iamsession.MVNO_ID = 1; iamsession.IMSI = stock.IMSI; iamsession.SIM_ItemCode = stock.MODEL_ID; StoreSIM storeSIM = new StoreSIM(); storeSIM.ICCID = ICCID; storeSIM.MVNO_ID = iamsession.MVNO_ID; storeSIM.IMSI = stock.IMSI; storeSIM.PUK1 = stock.PUK1; try { db.IAMSessions.Add(iamsession); db.StoreSIMs.Add(storeSIM); db.SaveChanges(); return(Content("0")); }catch (DbEntityValidationException e) { return(Content(e.EntityValidationErrors.ToString())); } }