public void UpdateCard(Card card) { Card dbEntry = context.Cards.Find(card.c_ID); if (dbEntry != null) { dbEntry.c_Index = card.c_Index; dbEntry.c_Name = card.c_Name; dbEntry.c_Minutes = card.c_Minutes; dbEntry.c_StartHour = card.c_StartHour; dbEntry.c_FixedHour = card.c_FixedHour; dbEntry.c_Done = card.c_Done; } context.SaveChanges(); }
public int SaveCard(Card card) { if (card.c_ID == 0) { context.Cards.Add(card); context.SaveChanges(); return card.c_ID; } else { Card dbEntry = context.Cards.Find(card.c_ID); if (dbEntry != null) { dbEntry.c_Index = card.c_Index; } context.SaveChanges(); return dbEntry.c_ID; } }
public void DeleteCard(Card card) { Card dbEntry = context.Cards.Find(card.c_ID); context.Cards.Remove(dbEntry); context.SaveChanges(); }
public ActionResult UpdateCard(CardModel model) { Card card = new Card { c_ID = model.cID, c_DayID = model.DayId, c_Index = model.Index, c_Name = model.Name, c_Minutes = model.Minutes, c_StartHour = model.StartHour, c_FixedHour = model.Fixed, c_Done = model.Done }; repositoryCard.UpdateCard(card); //sa updatez indecsii pt ca nu ii corectez altfel List<Card> lstCards = repositoryCard.Cards .Where(c => c.c_DayID == model.DayId) .OrderBy(c => c.c_StartHour) .ToList(); for(int i = 0; i < lstCards.Count; i++) { lstCards[i].c_Index = i; repositoryCard.UpdateCard(lstCards[i]); } return RedirectToAction("ListDays", "Day"); }