public static void BeginInsurance(Person p_person, DateTime p_start, DateTime p_end, int p_franchise, int p_paymentMethod) { InsuranceDetails details = null; double erstePraemie = 0.00; if (p_end < p_start) { throw new Exception("Enddatum liegt vor dem Startdatum"); } using (AviertDataContext context = new AviertDataContext()) { // Start- und Enddatum setzen details = context.InsuranceDetails.Single(d => d.PersonId == p_person.PersonId); details.StartDate = p_start; details.EndDate = p_end; details.Franchise = p_franchise; details.Status = (int)InsuranceStatus.Pending; // Aenderungen uebernehmen context.SubmitChanges(); } erstePraemie = PraemienHelper.GetErstePraemie((int)details.Franchise, (DateTime)details.StartDate, p_paymentMethod); DatatransHelper.CreateTransaction(details, erstePraemie); }
public static void CreatePerson(ref Person p_person) { using (AviertDataContext context = new AviertDataContext()) { context.Person.InsertOnSubmit(p_person); context.SubmitChanges(); } }
public static void EndInsurance(Person p_person, DateTime p_endDate) { InsuranceDetails details = null; using (AviertDataContext context = new AviertDataContext()) { // Enddatum setzen details = context.InsuranceDetails.SingleOrDefault(d => d.PersonId == p_person.PersonId); details.EndDate = p_endDate; details.Status = (int)InsuranceStatus.Terminated; // Aenderungen uebernehmen context.SubmitChanges(); } }
public static InsuranceDetails CreateInsuranceDetails(Person p_person) { InsuranceDetails details = null; details = new InsuranceDetails() { PersonId = p_person.PersonId, InsertDate = DateTime.Now, Status = (int)InsuranceStatus.Created }; using (AviertDataContext context = new AviertDataContext()) { context.InsuranceDetails.InsertOnSubmit(details); context.SubmitChanges(); } return (details); }
public static void BatchExecuteTransactions(IEnumerable<DatatransTransaction> p_transactions) { string xml_request = null; foreach (DatatransTransaction transaction in p_transactions) { transaction.Status = (short)TransactionStatus.Pending; } using (AviertDataContext context = new AviertDataContext()) { context.DatatransTransaction.InsertAllOnSubmit(p_transactions); context.SubmitChanges(); } foreach (DatatransTransaction transaction in p_transactions) { xml_request = GetXmlTransaction(transaction); DoWebRequest(xml_request); } }
public static void UpdateLastLogin(User p_user) { User user = null; using (AviertDataContext context = new AviertDataContext()) { user = context.User.SingleOrDefault(u => u.UserId == p_user.UserId); user.LastLogin = DateTime.Now; context.SubmitChanges(); } }
public static void SetPassword(User p_user, string p_password) { User user = null; using (AviertDataContext context = new AviertDataContext()) { user = context.User.SingleOrDefault(u => u.UserId == p_user.UserId); user.Password = EncryptPassword(p_password); user.PasswordDate = DateTime.Now; context.SubmitChanges(); } }
public static void CreateUser(ref User p_user) { if (string.IsNullOrEmpty(p_user.Username) || string.IsNullOrEmpty(p_user.Password)) { throw new Exception("Fehler beim Erstellen des Benutzers."); } if (CheckIfUserExists(p_user.Username)) { throw new Exception("Der Benutzer existiert bereits."); } p_user.Password = EncryptPassword(p_user.Password); p_user.Status = (int)UserStatus.Created; p_user.CreationDate = DateTime.Now; p_user.PasswordDate = DateTime.Now; using (AviertDataContext context = new AviertDataContext()) { context.User.InsertOnSubmit(p_user); context.SubmitChanges(); } }
public static void CreateAlias(string p_transactionRef, string p_masked, string p_alias, string p_expMonth, string p_expYear) { DatatransTransaction transaction = null; long id = -1; p_transactionRef = p_transactionRef.TrimStart('0'); id = long.Parse(p_transactionRef); using (AviertDataContext context = new AviertDataContext()) { transaction = context.DatatransTransaction.Single(t => t.TransactionId == id); CreditCardAlias alias = new CreditCardAlias() { Alias = p_alias, MaskedCcNumber = p_masked, ExpirationMonth = int.Parse(p_expMonth), ExpirationYear = int.Parse(p_expYear), InsuranceId = (int)transaction.DetailsId }; context.CreditCardAlias.InsertOnSubmit(alias); context.SubmitChanges(); } }
public static void ConfirmTransaction(string p_transaction, string p_uppTransactionId, string p_pmethod, string p_authorizationCode, string p_responseMessage, string p_status) { DatatransTransaction transaction = null; long id = 0; TransactionStatus status = TransactionStatus.Unknown; if ("success".Equals(p_status)) { status = TransactionStatus.Authorized; } else if ("error".Equals(p_status)) { status = TransactionStatus.Rejected; } else if ("cancel".Equals(p_status)) { status = TransactionStatus.Cancelled; } p_transaction = p_transaction.TrimStart('0'); id = long.Parse(p_transaction); using (AviertDataContext context = new AviertDataContext()) { transaction = context.DatatransTransaction.Single(t => t.TransactionId == id); transaction.DT_uppTransactionId = p_uppTransactionId; transaction.DT_pmethod = p_pmethod; transaction.DT_authorizationCode = p_authorizationCode; transaction.DT_responseMessage = p_responseMessage; transaction.Status = (short)status; context.SubmitChanges(); } }
public static DatatransTransaction CreateTransaction(InsuranceDetails p_details, double p_amount) { DatatransTransaction transaction = null; transaction = new DatatransTransaction() { DetailsId = p_details.DetailsId, Amount = (decimal)p_amount, Status = (int)TransactionStatus.Pending, InsDate = DateTime.Now }; using (AviertDataContext context = new AviertDataContext()) { context.DatatransTransaction.InsertOnSubmit(transaction); context.SubmitChanges(); } return (transaction); }
public static void InactivateExpiresInsurances() { IEnumerable<InsuranceDetails> expiredInsurances = null; using (AviertDataContext context = new AviertDataContext()) { expiredInsurances = context.InsuranceDetails.Where(d => d.Status == (int)InsuranceStatus.Active && (d.EndDate != null && d.EndDate < DateTime.Now)); foreach (InsuranceDetails details in expiredInsurances) { details.Status = (int)InsuranceStatus.Terminated; } context.SubmitChanges(); } }