public void UpdateClassPass(Class_Passes pass) { var ocp = myDb.Class_Passes.Where(x => x.Pass_Id == pass.Pass_Id).Single(); Class_Passes ncp = new Class_Passes(); ocp.Pass_Name = pass.Pass_Name; ocp.Pass_Size = pass.Pass_Size; ocp.Pass_Price = pass.Pass_Price; ocp.Active = pass.Active; myDb.SaveChanges(); }
public void CreateClassPass(Class_Passes cp) { myDb.Class_Passes.Add(cp); myDb.SaveChanges(); }
public Pass_Log processPurchase(Class_Passes pass, int userId, string purchaseType) { Pass_Log pass_Log = new Pass_Log(); Promotion p = getPromotionByPassId(pass.Pass_Id); pass_Log.Pass_Id = pass.Pass_Id; pass_Log.U_Id = userId; pass_Log.Purchase_Method = purchaseType; int token; if (p != null) { if (p.Num_Classes == 0) { token = pass.Pass_Size; pass_Log.Num_Classes = token; } else { token = pass.Pass_Size + (int)p.Num_Classes; pass_Log.Num_Classes = token; } if (p.Discount == 0) { pass_Log.Purchase_Price = decimal.Round(pass.Pass_Price * (decimal)1.15, 2); } else { decimal subtotal = decimal.Round((pass.Pass_Price - (pass.Pass_Price * (decimal)p.Discount)), 2); pass_Log.Purchase_Price = decimal.Round((subtotal * (decimal)1.15), 2); } } else { token = pass.Pass_Size; pass_Log.Num_Classes = token; pass_Log.Purchase_Price = decimal.Round(pass.Pass_Price * (decimal)1.15, 2); } AddTokens(userId, token); DateTime date = DateTime.Now; pass_Log.Date_Purchased = date; CreatePass_Log(pass_Log); string purchaseDateTime = date.ToString("dd/MM/yyyy HH:mm:ss"); string purchaseDate = date.ToString("ddMMyy"); Pass_Log pl = getPassLog(date, userId); string invoiceNumber = userId.ToString() + pl.Pass_Log_Id; pl.Invoice_Number = Int32.Parse(invoiceNumber); myDb.SaveChanges(); return(pl); }