public int SaveTable(SmallDataTest element) { try { int res = GetTableItem(element.productID, element.UserName); if (res == 0) { db.SmallDataTest.Add(element); db.SaveChanges(); } else { element.id = res; try { db.Entry(element).State = EntityState.Modified; db.SaveChanges(); } catch (OptimisticConcurrencyException ex) { RDL.Debug.LogError(ex); } } } catch (Exception ex) { RDL.Debug.LogError(ex); } return(1); }
public JsonResult EditTable(int productID) { SmallDataManager mng = new SmallDataManager(); if (User.Identity.IsAuthenticated) { SmallDataTest res = new SmallDataTest(); res.UserName = User.Identity.Name; res.productID = productID; res.visitedDate = DateTime.Now; mng.SaveTable(res); } var res2 = mng.GetTable().Select(x => new { productID = x.productID, UserName = x.UserName, d = x.visitedDate.Value.Day, m = x.visitedDate.Value.Month, y = x.visitedDate.Value.Year }); return(Json(res2, JsonRequestBehavior.AllowGet)); }
internal int SaveTable(SmallDataTest item) { var res = db.SaveTable(item); return(res); }