Esempio n. 1
0
        public ActionResult Create(merchant_advertisers Advertiser)
        {
            String tReturn = "";

            try
            {
                Models.AdvertiserModel tModel = new Models.AdvertiserModel();
                if (tModel.Create(Advertiser) == true)
                {
                    tReturn = "{\"status\":\"ok\"}";
                }
                else
                {
                    tReturn = "{\"status\":\"Failed\"}";
                }
            }
            catch
            {
                tReturn = "{\"status\":\"Failed\"}";
            }
            finally
            {
            }
            return(Json(tReturn, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
 public bool Create(merchant_advertisers tMerchant)
 {
     try
     {
         DB.merchant_advertisers.Add(tMerchant);
         DB.SaveChanges();
     }
     catch (DbUpdateException ex)
     {
         String Message = "Create MerchantAdvertisers: " + ex.Message + ex.InnerException != null ? " InnerException: " + ex.InnerException.Message : "";
         System.Console.WriteLine(Message);
         return(false);
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException ex)
     {
         String Message = "Create MerchantAdvertisers: " + ex.Message + ex.InnerException != null ? " InnerException: " + ex.InnerException.Message : "";
         System.Console.WriteLine(Message);
         return(false);
     }
     catch (Exception ex)
     {
         String Message = "Create MerchantAdvertisers: " + ex.Message + ex.InnerException != null ? " InnerException: " + ex.InnerException.Message : "";
         System.Console.WriteLine(Message);
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
 public bool Update(merchant_advertisers Advertiser)
 {
     try
     {
         DB.merchant_advertisers.Attach(Advertiser);
         DB.Entry(Advertiser).State = System.Data.Entity.EntityState.Modified;
         DB.SaveChanges();
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException ex)
     {
         String Message = "Create MerchantAdvertisers: " + ex.Message + ex.InnerException != null ? " InnerException: " + ex.InnerException.Message : "";
         System.Console.WriteLine(Message);
         return(false);
     }
     catch (Exception ex)
     {
         String Message = "Create MerchantAdvertisers: " + ex.Message + ex.InnerException != null ? " InnerException: " + ex.InnerException.Message : "";
         System.Console.WriteLine(Message);
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
        public ActionResult ChangeAdvertiser(int id, merchant_advertisers collection)
        {
            String tReturn = "";

            try
            {
                Models.AdvertiserModel tModel = new Models.AdvertiserModel();

                if (tModel.Update(collection))
                {
                    tReturn = "{\"status\":\"ok\"}";
                }
                {
                    tReturn = "{\"status\":\"failed\"}";
                }
            }
            catch
            {
                tReturn = "{\"status\":\"failed\"}";
                return(Json(tReturn, JsonRequestBehavior.AllowGet));
            }
            return(Json(tReturn, JsonRequestBehavior.AllowGet));
        }
 public bool Process(int userid, int merchantid, decimal AmountRedeemed)
 {
     try
     {
         /*
          * If the Server does NOT find the user_id in the users table AND the merchant_id in the merchant_advertisers table, then Server creates a record in the sallikasu_redemptions table..
          */
         user tUser = (from u in DB.users where u.id == userid select u).FirstOrDefault();
         if (tUser == null)
         {
             merchant_advertisers tAdvert = (from ma in DB.merchant_advertisers where ma.merchant_id == merchantid select ma).FirstOrDefault();
             if (tAdvert == null)
             {
                 nastha_redemptions tRedemption = new nastha_redemptions();
                 tRedemption.amount_redeemed = AmountRedeemed;
                 tRedemption.created_at      = tRedemption.updated_at = DateTime.Now;
                 tRedemption.merchant_id     = merchantid;
                 tRedemption.user_id         = userid;
                 DB.nastha_redemptions.Add(tRedemption);
                 DB.SaveChanges();
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
        public bool Process(int merchantid, decimal amount_deposit)
        {
            try
            {
                merchant_advertisers tMerchant = (from m in DB.merchant_advertisers where m.merchant_id == merchantid select m).FirstOrDefault();
                if (tMerchant == null)
                {
                    return(false);
                }
                tMerchant.status           = "A";
                tMerchant.deposit_balance += amount_deposit;
                advertiser_deposit tAdDeposit = new advertiser_deposit();
                tAdDeposit.amount_deposit      = amount_deposit;
                tAdDeposit.deposit_received_dt = DateTime.Now;
                tAdDeposit.merchant_id         = merchantid;
                tAdDeposit.created_at          = DateTime.Now;
                DB.advertiser_deposit.Add(tAdDeposit);

                subscription tSub = (from s in DB.subscriptions where s.id == tMerchant.subscription_id select s).FirstOrDefault();
                if (tSub != null && tMerchant.deposit_balance > tSub.min_deposit_balance)
                {
                    tMerchant.merchant.opt_out = "N";
                }
                else
                {
                    return(false);
                }
                DB.merchant_advertisers.Attach(tMerchant);
                DB.SaveChanges();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
        public merchant_advertisers GetByMerchantId(int id)
        {
            merchant_advertisers tAdvt = (from m in DB.merchant_advertisers where m.merchant_id == id select m).SingleOrDefault();

            return(tAdvt);
        }