예제 #1
0
        public int AddCard(string code, int idStd, int status)
        {
            try
            {
                if (idStd != 0)
                {
                    var std = dbContext.Students.SingleOrDefault(x => x.ID == idStd);
                    std.Status = 1;
                }
                if (dbContext.RFIDCards.Where(x => x.CodeCard == code).Count() > 0)
                {
                    return(1);
                }

                var card = new RFIDCard();

                card.CodeCard  = code;
                card.IDStudent = idStd;
                card.Status    = status;
                dbContext.RFIDCards.Add(card);
                dbContext.SaveChanges();
                return(0);
            }
            catch
            {
                return(2);
            }
        }
 public IHttpActionResult AddCard(RFIDCard card)
 {
     if (BussinessLogic.Users.AddCardToUser(card.User, card.CardId))
     {
         return(Ok());
     }
     return(InternalServerError());
 }