// GET: Updates/GetPublicUpdates //POST: Updates/AddUpdatePublicUpdate // GET: Updates/Create public ActionResult Create() { int userId = DAL.GetUserId(User.Identity.Name); UserInfoModel info = DAL.GetUserInfo(userId); var now = (DateTime)DateTime.Now; ViewData["userinfo"] = info; var update = new Update { UpdateDate = now //UpdateTypeId = 1 }; return View(update); }
private static bool ExecuteDB(Update updates, DBQueryType queryType) { using (spiffaiwebEntities db = LoadDB()) { switch (queryType) { case DBQueryType.Add: db.Updates.Add(updates); break; case DBQueryType.Update: db.Updates.Attach(updates); db.Entry(updates).State = System.Data.Entity.EntityState.Modified; break; case DBQueryType.Delete: db.Updates.Remove(updates); break; default: break; } db.SaveChanges(); } return true; }
public static bool Delete(Update updates) { return ExecuteDB(updates, DBQueryType.Delete); }
public static bool Add(Update updates) { return ExecuteDB(updates, DBQueryType.Add); }
public static string AddEditUpdate(Update update) { spiffaiwebEntities db = new spiffaiwebEntities(); string response = ""; try { if (update.UpdateId > 0) { //Edit db.Entry(update).State = EntityState.Modified; db.SaveChanges(); response = "Succcess"; } else { //Create db.Updates.Add(update); db.SaveChanges(); response = "Success"; } } catch (Exception) { response = "Error"; throw; } return response; }