Exemple #1
0
        public static async Task <RO <string> > CardReplace(ReplacementCardData replacementCards)
        {
            var ro = new RO <string> {
                ReturnValue = string.Empty, ReturnCode = 0, Message = string.Empty
            };

            var cards   = _db.GetCollection <DBCard>("cards");
            var clients = _db.GetCollection <DBClient>("clients");

            var card = new DBCard {
                RFID = replacementCards.RFID
            };

            cards.Insert(card);

            var client = clients.FindById(int.Parse(replacementCards.CustomerKey));

            client.Cards.Add(card);
            clients.Update(client);

            card         = cards.FindOne(c => c.RFID.Equals(replacementCards.ReplacementRFID));
            card.Blocked = true;
            card.Deleted = true;
            cards.Update(card);

            card = client.Cards.Find(c => c.RFID == replacementCards.ReplacementRFID);
            client.Cards.Remove(card);
            clients.Update(client);

            return(await Task.FromResult(ro));
        }
Exemple #2
0
        public static async Task <RO <string> > CardNew(CardData cardNew)
        {
            var ro = new RO <string> {
                ReturnValue = string.Empty, ReturnCode = 0, Message = string.Empty
            };

            var cards   = _db.GetCollection <DBCard>("cards");
            var clients = _db.GetCollection <DBClient>("clients");

            var card = new DBCard {
                RFID = cardNew.RFID
            };

            cards.Insert(card);

            var client = clients.FindById(int.Parse(cardNew.CustomerKey));

            client.Cards.Add(card);
            clients.Update(client);

            return(await Task.FromResult(ro));
        }