public virtual async Task <List <WorkOutModel> > GetList() { List <WorkOutModel> WorkOutList = new List <WorkOutModel>(); using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("WorkOut_GetList", connection)) { command.CommandType = CommandType.StoredProcedure; await connection.OpenAsync(); using (SqlDataReader reader = await command.ExecuteReaderAsync()) { while (reader.Read()) { WorkOutModel WorkOut = new WorkOutModel(); WorkOut.ID = (int)reader["ID"]; WorkOut.Name = reader["WName"].ToString(); WorkOut.Description = reader["WDescription"].ToString(); WorkOut.Rating = (int)reader["WRating"]; WorkOut.Date = (DateTime)reader["WDate"]; WorkOut.PostedBy = reader["PostedBy"].ToString(); WorkOutList.Add(WorkOut); } } } } WorkOutList.Sort(new WorkoutComparer()); return(WorkOutList); }
private async Task CreateNewCalendar() { var datePicked = startDate.Date; try { for (int i = 0; i < workOutList.Count; i++) { WorkOutModel itemsList = new WorkOutModel() { Title = selectedProgram, WorkOutTitle = workOutList[i], Date = datePicked.AddDays(i), Done = false }; await _connection.InsertAsync(itemsList); _workOuts.Add(itemsList); } await DisplayAlert("Calendar Created", $"{selectedProgram} WorkOut Calendar has been created.", "Great!"); } catch (Exception) { await DisplayAlert("Error", "Something went wrong! please try again", "OK"); } }
public virtual WorkOutModel Get(int id) { WorkOutModel WorkOut = null; using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("WorkOut_Get", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@ID", id); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { WorkOut = new WorkOutModel(); WorkOut.ID = (int)reader["ID"]; WorkOut.Name = reader["WName"].ToString(); WorkOut.Description = reader["WDescription"].ToString(); WorkOut.Rating = (int)reader["WRating"]; WorkOut.Date = (DateTime)reader["WDate"]; WorkOut.PostedBy = reader["PostedBy"].ToString(); } } } } return(WorkOut); }
public IActionResult PostBlog() { WorkOutModel model = new WorkOutModel(); model.Rating = 5; model.Date = DateTime.Now; return(View(model)); }
public IActionResult PostBlog(WorkOutModel model) { if (!ModelState.IsValid) { return(View(model)); //return RedirectToAction("Index"); } return(Create(model)); }
public IActionResult PostBlog() { WorkOutModel model = new WorkOutModel(); model.WName = _Settings.DefaultName; model.WRating = _Settings.DefaultRating; model.PostedBy = _Settings.DefaultUser; return(View(model)); }
public virtual void Save(WorkOutModel WorkOut) { using (SqlConnection connection = new SqlConnection(conString)) { using (SqlCommand command = new SqlCommand("WorkOut_InsertUpdate", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); command.Parameters.AddWithValue("@ID", WorkOut.ID); command.Parameters.AddWithValue("@WName", WorkOut.Name); command.Parameters.AddWithValue("@WDescription", WorkOut.Description); command.Parameters.AddWithValue("@WRating", WorkOut.Rating); command.Parameters.AddWithValue("@WDate", WorkOut.Date); command.Parameters.AddWithValue("@PostedBy", WorkOut.PostedBy); int rows = command.ExecuteNonQuery(); if (rows <= 0) { Console.Error.WriteLine("Didn't Work"); } } } }
public IActionResult View(int id) { WorkOutModel a = _WorkOutRepo.Get(id); return(View(a)); }
public IActionResult Edit(int id) { WorkOutModel WorkOut = _WorkOutRepo.Get(id); return(View(WorkOut)); }
protected IActionResult Create(WorkOutModel model) { _WorkOutRepo.Save(model); return(RedirectToAction("Index")); }
public override void Save(WorkOutModel WorkOut) { base.Save(WorkOut); _Cache.Remove(_CacheListKey); }