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");
        }
Exemple #2
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;
        }
Exemple #3
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));
     }
 }