public ActionResult ModifyGuide(GuideDto guide) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_Guides theGuide = db.T_Guides.FirstOrDefault(a => a.GuideID == guide.GuideID); theGuide.Tel = guide.Tel; theGuide.Contact = guide.Contact; theGuide.LandFee = guide.LandFee; theGuide.SeaFee = guide.SeaFee; theGuide.AgentLandFee = guide.AgentLandFee; theGuide.AgentSeaFee = guide.AgentSeaFee; theGuide.Remark = guide.Remark; theGuide.SupplierID = guide.SupplierID; db.T_Guides.Attach(theGuide); db.Entry(theGuide).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 AddNewGuide(GuideDto newGuide) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_Guides guide = new T_Guides { GuideName = newGuide.GuideName, Tel = newGuide.Tel, Contact = newGuide.Contact, LandFee = newGuide.LandFee, AgentLandFee = newGuide.AgentLandFee, SeaFee = newGuide.SeaFee, AgentSeaFee = newGuide.AgentSeaFee, Remark = newGuide.Remark, SupplierID = newGuide.SupplierID }; db.T_Guides.Add(guide); db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }