Beispiel #1
0
        public void BuyPlan(string userId, string planId)
        {
            PlanBuying buying;

            if (planId.Contains('s'))
            {
                buying = new PlanService().GetPlanBuying(userId);
                if (buying == null)
                {
                    buying = new PlanBuying
                    {
                        Id_plan      = planId,
                        Id_user      = userId,
                        MoneyBalance = 0
                    };
                }
                else
                {
                    new PlanService().PlanBuyingDelete(buying);
                }
                buying.MoneyBalance += new PlanService().GetPlanPrice(planId);
                buying.BuyingDate    = DateTime.Now;
                buying.isHide        = 0;
            }
            else
            {
                buying = new PlanBuying
                {
                    Id_plan    = planId,
                    Id_user    = userId,
                    BuyingDate = DateTime.Now,
                    isHide     = 0
                };
                buying.ImageBalance = new PlanService().GetPlanImages(planId);
            }
            new PlanService().PlanBuyingAdd(buying);
        }
Beispiel #2
0
 public void PlanBuyingDelete(PlanBuying buying)
 {
     db.PlanBuyings.Remove(buying);
     db.SaveChanges();
 }
Beispiel #3
0
 public void PlanBuyingAdd(PlanBuying buying)
 {
     db.PlanBuyings.Add(buying);
     db.SaveChanges();
 }