public MembershipCreateStatus UpdateCustomer(ExtendedCustomer customer)
        {
            try
            {
                using (var db = new JONEntities())
                {
                    var existingCustomer = db.usr_CUSTOMERS.Where(x => x.email == customer.Email).SingleOrDefault();

                    var source = new MergeExistingCustomerAndExtendedCustomer();
                    source.First  = existingCustomer;
                    source.Second = customer;

                    var customerdto = mapper.Map <MergeExistingCustomerAndExtendedCustomer, usr_CUSTOMERS>(source);

                    db.usr_CUSTOMERS.Detach(existingCustomer);
                    db.usr_CUSTOMERS.Attach(customerdto);

                    db.ObjectStateManager.ChangeObjectState(customerdto, EntityState.Modified);

                    //   db.usr_CUSTOMERS.AddObject(customerdto);
                    db.SaveChanges();

                    return(MembershipCreateStatus.Success);
                }
            }
            catch (Exception ex)
            {
                return(MembershipCreateStatus.ProviderError);
            }
        }
        public MembershipCreateStatus CreateExtendedCustomer(ExtendedCustomer customer,string password)
        {
            var customerdto = mapper.Map<ExtendedCustomer, usr_CUSTOMERS>(customer);
            customerdto.password = password;
            try
            {
                using (var db = new JONEntities())
                {
                    db.usr_CUSTOMERS.AddObject(customerdto);
                    db.SaveChanges();

                    return MembershipCreateStatus.Success;
                }
            }
            catch (Exception ex)
            {
                return MembershipCreateStatus.ProviderError;
            }
        }
        public MembershipCreateStatus CreateExtendedCustomer(ExtendedCustomer customer, string password)
        {
            var customerdto = mapper.Map <ExtendedCustomer, usr_CUSTOMERS>(customer);

            customerdto.password = password;
            try
            {
                using (var db = new JONEntities())
                {
                    db.usr_CUSTOMERS.AddObject(customerdto);
                    db.SaveChanges();

                    return(MembershipCreateStatus.Success);
                }
            }
            catch (Exception ex)
            {
                return(MembershipCreateStatus.ProviderError);
            }
        }
 public ActionResult UpdateCustomerDetails(ExtendedCustomer extendedCustomer)
 {
     var status = customerAccountService.UpdateCustomer(extendedCustomer);
     if (status == MembershipCreateStatus.Success)
     {
         return RedirectToAction("Index","MyAccount");
     };
     return RedirectToAction("ReportError","Services",new ReportErrorViewModel
                                                          {
                                                              ErrorMessage = "Can't update user details"
                                                          });
 }
        public MembershipCreateStatus UpdateCustomer(ExtendedCustomer customer)
        {
            try
            {
                using (var db = new JONEntities())
                {
                    var existingCustomer = db.usr_CUSTOMERS.Where(x => x.email == customer.Email).SingleOrDefault();

                    var source = new MergeExistingCustomerAndExtendedCustomer();
                    source.First = existingCustomer;
                    source.Second = customer;

                    var customerdto = mapper.Map<MergeExistingCustomerAndExtendedCustomer, usr_CUSTOMERS>(source);

                    db.usr_CUSTOMERS.Detach(existingCustomer);
                    db.usr_CUSTOMERS.Attach(customerdto);

                    db.ObjectStateManager.ChangeObjectState(customerdto, EntityState.Modified);

                 //   db.usr_CUSTOMERS.AddObject(customerdto);
                    db.SaveChanges();

                    return MembershipCreateStatus.Success;
                }
            }
            catch (Exception ex)
            {
                return MembershipCreateStatus.ProviderError;
            }
        }
        private ICustomerAccountService CreateCustomerAccountServiceWithExtendedCustomer(ExtendedCustomer extendedCustomer)
        {
            var customerAccountService = MockRepository.GenerateStub<ICustomerAccountService>();
            customerAccountService.Stub(x => x.GetExtendedCustomerByEmail(Arg<string>.Is.Anything)).
                Return(extendedCustomer);

            return customerAccountService;
        }
 public MembershipCreateStatus CreateExtendedCustomer(ExtendedCustomer customer, string password)
 {
     throw new NotImplementedException();
 }
 public MembershipCreateStatus UpdateCustomer(ExtendedCustomer customer)
 {
     throw new NotImplementedException();
 }