public bool UpdateDashboardTable(DashboardTable_Model DashboardTable) { using (var _context = new SalesTrackingSystemEntities()) { try { var data = _context.DashboardTables.Where(dashboardTable => dashboardTable.DashboardTableId == DashboardTable.DashboardTableId).FirstOrDefault(); data.DashboardTableId = DashboardTable.DashboardTableId; data.TableName = DashboardTable.TableName; data.DateUpdated = DateTime.Now; _context.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public ActionResult TableDelete(DashboardTable_Model table_Model) { var Type_Name = table_Model.TableName; try { if (DashboardTable_Interface.DeleteDashboardTable(table_Model.DashboardTableId)) { return(Json(Type_Name + " type has been deleted successfully")); } else { return(Json("Error")); } } catch (Exception e) { return(Json("Error" + e.ToString())); } }
public ActionResult TableAdd(DashboardTable_Model table_Model) { if (string.IsNullOrEmpty(table_Model.TableName)) { ViewBag.TableAddError = "Error"; return(View("Settings")); } else { if (DashboardTable_Interface.SaveDashboardTable(table_Model)) { Session["Success"] = table_Model.TableName + " added successfully!!"; } else { Session["Error"] = table_Model.TableName + " couldn't be added please retry!!"; } return(RedirectToAction("Settings")); } }
public ActionResult TableUpdate(DashboardTable_Model table_Model) { if (string.IsNullOrEmpty(table_Model.TableName)) { ViewBag.UpdateTableError = "Error"; ViewBag.UpdateTableData = table_Model.DashboardTableId; return(View("Settings")); } else { if (DashboardTable_Interface.UpdateDashboardTable(table_Model)) { Session["Success"] = table_Model.TableName + " updated successfully!!"; return(RedirectToAction("Settings")); } else { Session["Error"] = table_Model.TableName + " couldn't be updated please retry!!"; return(View("Settings")); } } }
public bool SaveDashboardTable(DashboardTable_Model DashboardTable) { using (var _dbContext = new SalesTrackingSystemEntities()) { try { var data = new DashboardTable() { DashboardTableId = GetNewDashboardTableID(), TableName = DashboardTable.TableName, DateCreated = DateTime.Now }; _dbContext.DashboardTables.Add(data); _dbContext.SaveChanges(); return(true); } catch (Exception) { throw; } } }