Ejemplo n.º 1
0
        private void InsertData()
        {
            CityStateZip cityStateZip = new CityStateZip();
            cityStateZip.City = acctCity.Text;
            cityStateZip.State = acctState.Text;
            cityStateZip.ZipCode = acctZipCode.Text;
            CityStateZipLogic cszLogic = new CityStateZipLogic();
            cityStateZip = cszLogic.InsertCityStateZip(cityStateZip);

            PaymentInfo paymentInfo = new PaymentInfo();
            paymentInfo.AmazonToken = "test";
            PaymentInfoLogic piLogic = new PaymentInfoLogic();
            paymentInfo = piLogic.InsertPaymentInfo(paymentInfo);

            Client client = new Client();
            client.ClientName = acctCompanyName.Text;
            client.PhoneNumber = acctPhoneNumber.Text;
            client.Email = acctEmail.Text;
            client.Address = acctAddress.Text;
            client.CityStateZipGuid = cityStateZip.CityStateZipGuid;
            client.PaymentInfoGuid = paymentInfo.PaymentInfoGuid;
            ClientLogic clientLogic = new ClientLogic();
            client = clientLogic.InsertClient(client);

            Response.Redirect(string.Format("CreateListing.aspx?ClientGuid={0}", client.ClientGuid));
        }
Ejemplo n.º 2
0
        public ActionResult AccountToggle(AccountViewModel account)
        {
            ClientLogic clientLogic = new ClientLogic();
            Client client = clientLogic.GetClientByClientGuid(account.ClientGuid);
            if (null == client)
            {
                return RedirectToAction("See");
            }
            // toggle account paused flag
            client.AccountPaused = !account.PauseAccount;
            clientLogic.UpdateClient(client);

            return RedirectToAction("See");
        }
Ejemplo n.º 3
0
 public List<DC.Client> GetAllClientWithUndefined()
 {
     try
     {
         BL.ClientLogic clientLogic = new BL.ClientLogic();
         List<BE.Client> entities = clientLogic.GetAllClientWithUndefined();
         List<DC.Client> response = entities.ToDataContractList();
         return response;
     }
     catch (Exception ex)
     {
         FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
         fault.ErrorMessage = "Unable to retrieve client data.";
         throw new FaultException<FC.DefaultFaultContract>(fault,
             new FaultReason(ex.Message));
     }
 }
Ejemplo n.º 4
0
        public void DeleteClient(DC.Client request)
        {
            try
            {
                BL.ClientLogic clientLogic = new BL.ClientLogic();
                BE.Client entity = request.ToBusinessEntity();
                clientLogic.DeleteClient(entity);
            }
            catch (BE.ClientNotFoundException ex)
            {
                FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
                fault.ErrorMessage = String.Format(
                    "Unable to delete Client data. Data: {0}",
                    request.ToBusinessEntity().ToString());

                throw new FaultException<FC.DefaultFaultContract>(fault,
                    new FaultReason(ex.Message));
            }
        }
Ejemplo n.º 5
0
        public bool Delete(Guid facilityGuid, string email)
        {
            bool success = false;
            FacilityLogic facilityLogic = new FacilityLogic();
            BE.Facility facility = facilityLogic.GetFacilityByFacilityGuid(facilityGuid);
            ClientLogic clientLogic = new ClientLogic();
            BE.Client client = clientLogic.GetClientByClientGuid(facility.ClientGuid);
            if (client.Email == email)
            {
                // to delete facility first delete related records in FacilityPhoto and FacilityOffering
                // !!! in the existing business model transaction scope is hard to implement !!!
                FacilityOfferingLogic facilityOfferingLogic = new FacilityOfferingLogic();
                FacilityPhotoLogic facilityPhotoLogic = new FacilityPhotoLogic();
                OfferingLogic offeringLogic = new OfferingLogic();
                // delete related offerings
                var facilityOfferings = offeringLogic.GetOfferingsForFacility(facilityGuid);
                if (facilityOfferings.Count > 0)
                {
                    facilityOfferings.ForEach(fo =>
                    {
                        facilityOfferingLogic.DeleteFacilityOffering(
                            new BE.FacilityOffering { FacilityGuid = facilityGuid, OfferingGuid = fo.OfferingGuid }
                        );
                    });
                }
                // delete related photos
                var facilityPhotos = facilityPhotoLogic.GetFacilityPhotosForFacilityByFacilityGuid(facilityGuid);
                if (facilityPhotos.Count > 0)
                {
                    facilityPhotos.ForEach(fp => facilityPhotoLogic.DeleteFacilityPhoto(fp));
                }

                facilityLogic.DeleteFacility(facility);
                success = true;
            }

            return success;
        }
Ejemplo n.º 6
0
        private void SaveAccount(ClientLogic clientLogic, AccountViewModel account, MembershipUser user, bool insert)
        {
            // Call business logic to insert the data.
            // todo: move to mapping
            CityStateZip cityStateZip = new CityStateZip
            {
                City = account.City,
                State = account.State,
                ZipCode = account.ZipCode
            };
            this.AddCityStateZipToAccount(account, cityStateZip);

            PaymentInfo paymentInfo = new PaymentInfo
            {
                AmazonToken = User.Identity.Name
            };
            this.AddPaymentInfoToAccount(account, paymentInfo);

            Client client = new Client();
            client.ClientName = account.ClientName;
            client.PhoneNumber = account.PhoneNumber;
            client.Email = user.UserName;
            client.Address = account.Address;
            client.CityStateZipGuid = account.CityStateZipGuid;
            client.PaymentInfoGuid = account.PaymentInfoGuid;
            // pause account - in create view is always false
            client.AccountPaused = account.PauseAccount;
            if (insert)
            {
                if (SessionHandler.Current.GitAssertion != null)
                {
                    GitAssertion assertion = SessionHandler.Current.GitAssertion;
                    client.FederatedIDProvider = assertion.Authority;
                    client.FederatedID = assertion.Identifier;
                    client.FederatedKey = user.ProviderUserKey.ToString();
                }

                client = clientLogic.InsertClient(client);
                account.ClientGuid = client.ClientGuid;
                account.ClientID = client.ClientID;
            }
            else
            {
                client.IsWaiverd = account.IsWaiverd;
                client.FreeDays = account.FreeDays;
                client.Credits = account.AccountBalance;
                client.IsSuspended = account.IsSuspended;
                client.IsActive = account.IsActive;
                client.ClientGuid = account.ClientGuid; // Had to add this......
                clientLogic.UpdateClient(client);
            }
        }
Ejemplo n.º 7
0
        public ActionResult EditClientCardInfo(ClientCardInfoViewModel clientCardInfoVM)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Please correct the errors and try again.");
                return View(clientCardInfoVM);
            }

            var user = Membership.GetUser();
            if (user == null)
            {
                return RedirectToAction("Create");
            }

            ClientLogic clientLogic = new ClientLogic();
            Client possibleClient = clientLogic.GetClientByEmail(user.UserName);

            if (null == possibleClient)
            {
                return RedirectToAction("Create");
            }
            clientCardInfoVM.ClientGuid = possibleClient.ClientGuid;
            this.SaveClientCardInfo(clientCardInfoVM, false);
            return RedirectToAction("see");
        }
Ejemplo n.º 8
0
        public ActionResult Edit(AccountViewModel account)
        {
            if (!ModelState.IsValid)
            {
                return View(account);
            }

            // Call business logic to insert the data.
            ClientLogic clientLogic = new ClientLogic();
            Client possibleClient = clientLogic.GetClientByEmail(account.Email);

            if (null == possibleClient)
            {
                return RedirectToAction("See");
            }

            this.SaveAccount(clientLogic, account, Membership.GetUser(), false);
            return RedirectToAction("See");
        }
Ejemplo n.º 9
0
        public ActionResult Create(AccountViewModel account)
        {
            // todo: implement some create account wizard when have more information
            if (!ModelState.IsValid)
            {
                return View(account);
            }

            // If logged in, show the appropriate view.
            var user = Membership.GetUser();
            if (user == null)
            {
                return RedirectToAction("Create");
            }

            ClientLogic clientLogic = new ClientLogic();
            // UserName is the email address they signed in with.
            Client possibleClient = clientLogic.GetClientByEmail(user.UserName);

            // If an account already exists for the user, show them the See page.
            if (null != possibleClient)
            {
                return RedirectToAction("See");
            }

            this.SaveAccount(clientLogic, account, user, true);
            return RedirectToAction("See");
        }
Ejemplo n.º 10
0
        public ActionResult ClientCardInfo(ClientCardInfoViewModel clientCardInfoVM)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Please correct the errors and try again.");
                return View(clientCardInfoVM);
            }

            var user = Membership.GetUser();
            if (user == null)
                return RedirectToAction("Create");

            ClientLogic clientLogic = new ClientLogic();
            // UserName is the email address they signed in with.
            Client possibleClient = clientLogic.GetClientByEmail(user.UserName);

            // If an account already exists for the user, show them the See page.
            if (null == possibleClient)
                return RedirectToAction("Create");
            clientCardInfoVM.ClientGuid = possibleClient.ClientGuid;
            this.SaveClientCardInfo(clientCardInfoVM, true);
            return RedirectToAction("See");
        }
Ejemplo n.º 11
0
 public DC.Client GetClientByClientGuid(Guid clientGuid)
 {
     try
     {
         BL.ClientLogic clientLogic = new BL.ClientLogic();
         BE.Client entity = clientLogic.GetClientByClientGuid(clientGuid);
         DC.Client response = entity.ToDataContract();
         return response;
     }
     catch (BE.ClientNotFoundException ex)
     {
         FC.ClientFault fault = new FC.ClientFault();
         fault.ClientGuid = ex.ClientGuid;
         fault.ErrorMessage = "Client does not exsist in the database.";
         throw new FaultException<FC.ClientFault>(fault,
             new FaultReason(ex.Message));
     }
     catch (Exception ex)
     {
         FC.ClientFault fault = new FC.ClientFault();
         fault.ErrorMessage = "Could not retrieve a specific Client for unknown reasons.";
         throw new FaultException<FC.ClientFault>(fault,
             new FaultReason(ex.Message));
     }
 }
Ejemplo n.º 12
0
 public List<DC.Client> GetClientsForPaymentInfoByPaymentInfoGuid(Guid paymentInfoGuid)
 {
     try
     {
         BL.ClientLogic clientLogic = new BL.ClientLogic();
         List<BE.Client> entities = clientLogic.GetClientsForPaymentInfoByPaymentInfoGuid(paymentInfoGuid);
         List<DC.Client> response = entities.ToDataContractList();
         return response;
     }
     catch (BE.ClientException ex)
     {
         FC.DefaultFaultContract fault = new FC.DefaultFaultContract();
         fault.ErrorMessage = string.Format("Unable to find a Client with the given PaymentInfo");
         throw new FaultException<FC.DefaultFaultContract>(fault,
             new FaultReason(ex.Message));
     }
 }