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); }
public void PlanBuyingDelete(PlanBuying buying) { db.PlanBuyings.Remove(buying); db.SaveChanges(); }
public void PlanBuyingAdd(PlanBuying buying) { db.PlanBuyings.Add(buying); db.SaveChanges(); }