public ActionResult Post(StoreVisit visitingSession) { if (ModelState.IsValid) { var storageVisit = new Visit { SessionId = visitingSession.SessionId, Timestamp = visitingSession.Timestamp, UserId = visitingSession.UserId, Paths = new List <Path>() }; foreach (var postPath in visitingSession.Path) { storageVisit.Paths.Add(new Path { DeviceId = postPath.DeviceId, Timestamp = postPath.Timestamp, }); } m_context.Visits.Add(storageVisit); m_context.SaveChanges(); return(NoContent()); } return(BadRequest(ModelState)); }
public IHttpActionResult Add() { try { var context = HttpContext.Current; //当前 var request = context.Request; //请求 var form = request.Form; //参数 this.Files = request.Files; //文件 //真实的参数 var parameters = Common.AesDecryp.GetAesDecryp(form["data"], form["secret"]); var StoreID = Convert.ToInt32(parameters["StoreID"]); using (dbDataContext db = new dbDataContext()) { var store = db.Store.Where(x => x.ID == StoreID).FirstOrDefault(); if (store != null) { StoreVisit model = new StoreVisit(); model.IsAgain = Convert.ToInt32(parameters["IsAgain"]); model.IsNeed = Convert.ToInt32(parameters["IsNeed"]); model.NextTime = parameters["NextTime"]; model.VisitTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //parameters["VisitTime"]; model.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.VisitContent = parameters["VisitContent"]; model.State = 0; model.Store = store; //最近更新时间 store.LastTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var names = "";// if (this.Files.Count > 0) { var result = Images_C("0", "Images", 0).Select(t => t).ToArray(); names = string.Join(";", result); model.VisitImg = names; } db.StoreVisit.InsertOnSubmit(model); db.SubmitChanges(); return(Json(new { state = 1, msg = "添加成功", })); } return(Json(new { state = 0, msg = "门店不存在" })); } } catch (Exception ex) { throw ex; } }
public IHttpActionResult Add() { try { var context = HttpContext.Current; //当前 var request = context.Request; //请求 var form = request.Form; //参数 this.Files = request.Files; //文件 //真实的参数 var parameters = Common.AesDecryp.GetAesDecryp(form["data"], form["secret"]); using (dbDataContext db = new dbDataContext()) { var UserID = Convert.ToInt32(parameters["UserID"]); var user = db.Users.FirstOrDefault(x => x.ID == UserID); if (user != null) { var model = new Store(); model.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.StoreName = parameters["StoreName"]; model.Broadband = parameters["Broadband"]; model.ContactName = parameters["ContactName"]; model.ContactTel = parameters["ContactTel"]; model.OverTime = parameters["OverTime"]; model.Price = parameters["Price"]; model.OtherNeeds = parameters["OtherNeeds"]; model.StoreAddress = parameters["StoreAddress"]; model.State = 0; model.Users = user; //最近更新时间 model.LastTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var names = "";// if (this.Files.Count > 0) { var result = Images_C("0", "Images", 0).Select(t => t).ToArray(); names = string.Join(";", result); model.Img = names; } //走访内容 var storeVisit = new StoreVisit(); storeVisit.IsAgain = Convert.ToInt32(parameters["IsAgain"]); storeVisit.IsNeed = Convert.ToInt32(parameters["IsNeed"]); storeVisit.NextTime = parameters["NextTime"]; storeVisit.VisitContent = parameters["TalkInfo"]; //本次洽谈内容 storeVisit.VisitTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //parameters["VisitTime"]; storeVisit.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); storeVisit.State = 0; storeVisit.Store = model; db.StoreVisit.InsertOnSubmit(storeVisit); db.Store.InsertOnSubmit(model); db.SubmitChanges(); return(Json(new { state = 1, msg = "添加成功", })); } return(Json(new { state = 0, msg = "该用户不存在" })); } } catch (Exception ex) { throw ex; } }
public IActionResult UpdateStoreVisit([FromBody] StoreVisit visit) { Repo.Update(visit); return(Ok(new { StoreVisitId = visit.StoreVisitId })); }
public IActionResult AddStoreVisit([FromBody] StoreVisit visit) { Repo.Add(visit); return(Ok(new { StoreVisitId = visit.StoreVisitId })); }