public ActionResult ModifyVipService(VIPDto vip) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_VIPs theVIP = db.T_VIPs.FirstOrDefault(a => a.ServerID == vip.ServerID); theVIP.ServerName = vip.ServerName; theVIP.Contact = vip.Contact; theVIP.Tel = vip.Tel; theVIP.Remark = vip.Remark; theVIP.SupplierID = vip.SupplierID; db.T_VIPs.Attach(theVIP); db.Entry(theVIP).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }
public ActionResult AddNewVipService(VIPDto vip) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_VIPs newVip = new T_VIPs { ServerName = vip.ServerName, Tel = vip.Tel, SupplierID = vip.SupplierID, Contact = vip.Contact, Remark = vip.Remark }; db.T_VIPs.Add(newVip); db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }