Пример #1
0
        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();
        }
Пример #2
0
 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;
     }
     
 }
Пример #3
0
 public void DeleteCard(Card card)
 {
     Card dbEntry = context.Cards.Find(card.c_ID);
     context.Cards.Remove(dbEntry);
     context.SaveChanges();
 }
Пример #4
0
        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");
        }