示例#1
0
 public string UpdateContacts(BillingContact contactBilling, ShippingContact contactShipping)
 {
     try
     {
         using (_context)
         {
             _context.SPUpdateContactInfo(Thread.CurrentPrincipal.Identity.Name, contactBilling.FirstName, contactBilling.LastName, contactBilling.Address, contactBilling.Apt, contactBilling.City, contactBilling.State, contactBilling.ZipCode, contactBilling.PhoneNumber, "", false);
             _context.SPUpdateContactInfo(Thread.CurrentPrincipal.Identity.Name, contactShipping.FirstName, contactShipping.LastName, contactShipping.Address, contactShipping.Apt, contactShipping.City, contactShipping.State, contactShipping.ZipCode, contactShipping.PhoneNumber, "", true);
             _context.SaveChanges();
             return("Saved");
         }
     }
     catch (Exception ex)
     {
         CustomLogging.LogMessage(TracingLevel.ERROR, new Exception("Error saving user contact information", ex));
         return("Failed");
     }
 }
示例#2
0
        public Contact GetUserContactInformation()
        {
            Contact contact = null;
            string  user    = Thread.CurrentPrincipal.Identity.Name;

            using (_context)
            {
                try
                {
                    _context.Database.Initialize(force: false);
                    using (var cmd = _context.Database.Connection.CreateCommand())
                    {
                        DbParameter parameter = cmd.CreateParameter();
                        parameter.ParameterName = "@username";
                        parameter.Value         = user;
                        cmd.Parameters.Add(parameter);
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.CommandText = "[dbo].[SPGetContactInformation]";
                        _context.Database.Connection.Open();
                        var reader = cmd.ExecuteReader();

                        BillingContact billing = ((IObjectContextAdapter)_context)
                                                 .ObjectContext
                                                 .Translate <BillingContact>(reader).SingleOrDefault();

                        reader.NextResult();
                        ShippingContact shipping = ((IObjectContextAdapter)_context)
                                                   .ObjectContext
                                                   .Translate <ShippingContact>(reader).SingleOrDefault();

                        contact = new Contact();
                        contact.BillingContact  = billing;
                        contact.ShippingContact = shipping;
                    }
                }
                catch (Exception ex)
                {
                    CustomLogging.LogMessage(TracingLevel.ERROR, new Exception("Error getting user contact information", ex));
                }
            }
            return(contact);
        }