Exemple #1
0
        public HttpResponseMessage useractivate(string username)
        {
            try
            {
                var ad = (from a in db.Admins
                          where a.UserName == username
                          select a).FirstOrDefault();

                if (ad.ActivationStatus == true)
                {
                    throw new Exception("UserActivated Already");
                }
                else
                {
                    ad.ActivationStatus = true;
                    CardTable ct = new CardTable();
                    ct.CardType = (from consumer in db.ConsumerTables
                                   where consumer.UserName == username
                                   select consumer.CardType).FirstOrDefault();
                    ct.Name            = username;
                    ct.RemainingCredit = (from cardtype in db.CardTypeTables
                                          where cardtype.CardType == ct.CardType
                                          select cardtype.TotalCredit).FirstOrDefault();
                    ct.TotalCredit = Convert.ToInt32((from cardtype in db.CardTypeTables
                                                      where cardtype.CardType == ct.CardType
                                                      select cardtype.TotalCredit).FirstOrDefault());
                    ct.ValidTill = db.validtill().FirstOrDefault().ToString();
                    db.CardTables.Add(ct);
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "UserActivated"));
                }
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Activation Failed"));
            }
        }