コード例 #1
0
        public GenericServiceContract UpdateCutomers(XElement customerData)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            string iGuonaCutomerID = null;
            List <Dictionary <string, ResponseStatus> > responseStatusList = new List <Dictionary <string, ResponseStatus> >();

            try
            {
                IEnumerable <XElement> cutomerList = from Cst in customerData.Elements()
                                                     select Cst;
                foreach (var customer in cutomerList)
                {
                    iGuonaCutomerID = customer.Element("IGuonaCutomerID").Value;
                    if (iGuonaCutomerID != null && iGuonaCutomerID != string.Empty)
                    {
                        Entity           customerEntity     = new Entity();
                        EntityCollection customerCollection = new EntityCollection();
                        QueryExpression  customerQuery      = new QueryExpression("contact");
                        customerQuery.ColumnSet = new ColumnSet(new string[] { "ohd_igounacustomerid" });
                        customerQuery.Criteria.AddCondition("ohd_igounacustomerid", ConditionOperator.Equal, iGuonaCutomerID);
                        customerCollection = OrganizationService.RetrieveMultiple(customerQuery);
                        if (customerCollection.Entities.Count == 1)
                        {
                            customerEntity = customerCollection.Entities.FirstOrDefault();
                            if (customer.Element("MobilePhone2").Value != string.Empty)
                            {
                                customerEntity["new_mobilephone2"] = customer.Element("MobilePhone2").Value;
                            }
                            if (customer.Element("MobilePhone").Value != string.Empty)
                            {
                                customerEntity["mobilephone"] = customer.Element("MobilePhone").Value;
                            }
                            if (customer.Element("MobilePhone3").Value != string.Empty)
                            {
                                customerEntity["new_mobilephone3"] = customer.Element("MobilePhone3").Value;
                            }
                            if (customer.Element("email1").Value != string.Empty)
                            {
                                customerEntity["emailaddress1"] = customer.Element("email1").Value;
                            }
                            if (customer.Element("email2").Value != string.Empty)
                            {
                                customerEntity["emailaddress2"] = customer.Element("email2").Value;
                            }
                            OrganizationService.Update(customerEntity);
                            responseStatusList.Add(new Dictionary <string, ResponseStatus>()
                            {
                                { iGuonaCutomerID, ResponseStatus.OK }
                            });
                        }
                        else if (customerCollection.Entities.Count == 0)
                        {
                            responseStatusList.Add(new Dictionary <string, ResponseStatus>()
                            {
                                { iGuonaCutomerID, ResponseStatus.CustomerIsNotFound }
                            });
                        }
                        else
                        {
                            responseStatusList.Add(new Dictionary <string, ResponseStatus>()
                            {
                                { iGuonaCutomerID, ResponseStatus.IGounaCustomerIDIsNotUnique }
                            });
                        }
                    }
                    else
                    {
                        responseStatusList.Add(new Dictionary <string, ResponseStatus>()
                        {
                            { iGuonaCutomerID, ResponseStatus.IGounaCustomerIDISEmpty }
                        });
                    }
                }
                responseMessage.ResponseStatus = new XElement("CustomerResponselist",
                                                              from rs in responseStatusList
                                                              select new XElement("Customer", new XAttribute("IGounaCustomerID", rs.Keys.FirstOrDefault()),
                                                                                  GetEnumDescription(rs.Values.FirstOrDefault())
                                                                                  ));
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #2
0
        public GenericServiceContract ChangeUnitArea(string iGounaUnitID, string buildUpArea)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            EntityCollection unitCollection = new EntityCollection();

            try
            {
                if (iGounaUnitID != null && iGounaUnitID != string.Empty)
                {
                    Entity          unit      = new Entity();
                    QueryExpression unitQuery = new QueryExpression(UnitEntity.SchemaName);
                    unitQuery.ColumnSet = new ColumnSet(new string[] { UnitEntity.Fields.UnitID, UnitEntity.Fields.UnitId, UnitEntity.Fields.iGounaUnitID });
                    unitQuery.Criteria.AddCondition(UnitEntity.Fields.iGounaUnitID, ConditionOperator.Equal, iGounaUnitID);
                    unitCollection = OrganizationService.RetrieveMultiple(unitQuery);
                    if (unitCollection.Entities.Count > 1)
                    {
                        //  IDGouna For More UNIT
                        responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaUnitIsNOtUnique);
                    }
                    else if (unitCollection.Entities.Count == 1)
                    {
                        if (buildUpArea != null && buildUpArea != string.Empty)
                        {
                            unit = unitCollection.Entities.FirstOrDefault();
                            decimal buildUPArea;
                            if (decimal.TryParse(buildUpArea, out buildUPArea))
                            {
                                unit[UnitEntity.Fields.BuiltUpArea] = buildUPArea;
                                OrganizationService.Update(unit);
                                responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.OK);
                            }
                            else
                            {
                                //not valid Built Up area
                                responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.BuildUpAreaIsNotValid);
                            }
                        }
                        else
                        {
                            // empty build up area
                            responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.BuildUpAreaIsEmptyOrNull);
                        }
                    }
                    else
                    {
                        //Not Found Unit
                        responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaOwnerNotFound);
                    }
                }
                else
                {
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaUnitNotVaild);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #3
0
        //public GenericServiceContract GetBuilding()
        //{
        //    OrganizationService = GetCrmService();

        //    XElement xml = new XElement("iGna",
        //        new XElement("SlsID", "TestA"),
        //        new XElement("opr", "TestB")

        //    );

        //    var response = new GenericServiceContract();
        //    response.ResponseObject = xml;

        //    return response;
        //}

        //Month-Day-Year
        public GenericServiceContract GetAllProjects(string createdOn)
        {
            //Todo .. Create new class for the response (Excpection , Description"Enum")
            //Naming of the varibales
            //Throw Exception in the response
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            EntityCollection projectCollection = new EntityCollection();

            try
            {
                QueryExpression projectQuery = new QueryExpression(LinkDev.OHDREM.Entities.Project.SchemaName);
                projectQuery.ColumnSet = new ColumnSet(new string[] { ProjectEntity.Fields.Name, ProjectEntity.Fields.ProjectId, ProjectEntity.Fields.Destination, ProjectEntity.Fields.Location, ProjectEntity.Fields.Initial, ProjectEntity.Fields.Country, ProjectEntity.Fields.Numberofunits, ProjectEntity.Fields.iGounaProjectID });
                if (createdOn != null && createdOn != string.Empty)
                {
                    DateTime CreatedOnDate = Convert.ToDateTime(createdOn);
                    projectQuery.Criteria.AddCondition(ProjectEntity.Fields.CreatedOn, ConditionOperator.Equal, CreatedOnDate);
                }

                projectCollection = OrganizationService.RetrieveMultiple(projectQuery);
                if (projectCollection.Entities.Count > 0)
                {
                    List <Project> projectList = new List <Project>();
                    XElement       projectXml  = null;
                    foreach (Entity projectEntity in projectCollection.Entities)
                    {
                        var project = new Project
                        {
                            Name            = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Name),
                            ProjectID       = GetAliasedValue2(projectEntity, ProjectEntity.Fields.ProjectId),
                            Destination     = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Destination, AliasTypes.EntityReference),
                            Location        = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Location),
                            Initial         = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Initial),
                            Country         = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Destination, AliasTypes.EntityReference),
                            NumberOfUnits   = GetAliasedValue2(projectEntity, ProjectEntity.Fields.Numberofunits),
                            iGounaProjectID = GetAliasedValue2(projectEntity, ProjectEntity.Fields.iGounaProjectID)
                        };
                        projectList.Add(project);
                    }
                    #region Convert Project List to Xml String
                    projectXml = new XElement("Projects", projectList.Select(x => new XElement("Project",
                                                                                               new XAttribute("ID", x.ProjectID),
                                                                                               new XElement("Name", x.Name),
                                                                                               new XElement("NumberOfUnits", x.NumberOfUnits),
                                                                                               new XElement("Initial", x.Initial),
                                                                                               new XElement("Location", x.Location),
                                                                                               new XElement("Country", x.Country),
                                                                                               new XElement("Destination", x.Destination),
                                                                                               new XElement("iGounaProjectID", x.iGounaProjectID))
                                                                             ));
                    #endregion
                    response.ResponseObject = projectXml;

                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.OK);
                }
                else
                {
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.ProjectsNotFound);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #4
0
        public GenericServiceContract ChangeUnitOwner(string iGounaUnitID, string iGounaOwnerID)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            try
            {
                if (iGounaUnitID != null && iGounaUnitID != string.Empty)
                {
                    if (iGounaOwnerID != null && iGounaOwnerID != string.Empty)
                    {
                        EntityCollection unitCollection  = new EntityCollection();
                        EntityCollection ownerCollection = new EntityCollection();
                        EntityCollection saleCollection  = new EntityCollection();
                        // Guid OwnerGuid = new Guid();
                        Entity unitEntity  = new Entity();
                        Entity ownerEntity = new Entity();
                        //get customer that contain IgounaOwnerId and check if is unique or not .
                        QueryExpression Ownerquery = new QueryExpression("contact");
                        Ownerquery.ColumnSet = new ColumnSet(new string[] { "contactid", "ohd_igounacustomerid" });
                        Ownerquery.Criteria.AddCondition("ohd_igounacustomerid", ConditionOperator.Equal, iGounaOwnerID);
                        ownerCollection = OrganizationService.RetrieveMultiple(Ownerquery);
                        if (ownerCollection.Entities.Count == 1)
                        {
                            ownerEntity = ownerCollection.Entities.FirstOrDefault();
                            QueryExpression UnitQuery = new QueryExpression(UnitEntity.SchemaName);
                            UnitQuery.ColumnSet = new ColumnSet(new string[] { UnitEntity.Fields.UnitID, UnitEntity.Fields.UnitId, UnitEntity.Fields.iGounaUnitID });
                            UnitQuery.Criteria.AddCondition(UnitEntity.Fields.iGounaUnitID, ConditionOperator.Equal, iGounaUnitID);
                            unitCollection = OrganizationService.RetrieveMultiple(UnitQuery);
                            if (unitCollection.Entities.Count > 1)
                            {
                                //  IDGounaUnit is not unique
                                responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaUnitIsNOtUnique);
                            }
                            else if (unitCollection.Entities.Count == 1)
                            {
                                unitEntity = unitCollection.Entities.FirstOrDefault();
                                //get sales with UnitId  and check if there are more one sale or not
                                QueryExpression SaleQuery = new QueryExpression("new_contracting");
                                SaleQuery.ColumnSet = new ColumnSet(new string[] { "new_contractingid", "new_customer", "new_name", "new_unit" });
                                if (unitEntity.Attributes.Contains("new_unitid"))
                                {
                                    Ownerquery.Criteria.AddCondition(UnitEntity.Fields.UnitId, ConditionOperator.Equal, unitEntity.Attributes[UnitEntity.Fields.UnitId]);
                                }
                                saleCollection = OrganizationService.RetrieveMultiple(SaleQuery);
                                if (saleCollection.Entities.Count == 1)
                                {
                                    Entity saleEntity = new Entity();
                                    saleEntity = saleCollection.Entities.FirstOrDefault();
                                    saleEntity["new_customer"] = new EntityReference("new_customer", (Guid)ownerEntity.Attributes["contactid"]);
                                    OrganizationService.Update(saleEntity);
                                }
                                else if (saleCollection.Entities.Count > 1)
                                {
                                    //more one sale have the same unit
                                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaUnitIsNOtUnique);
                                }
                                else
                                {
                                    // not found sale
                                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.SalesNotFound);
                                }
                            }
                            else
                            {
                                //Not Found Unit
                                responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.UnitNOtFound);
                            }
                        }
                        else if (ownerCollection.Entities.Count > 1)
                        {
                            // IdGounaOwner Isnot unique
                            responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaOwnerISNotUnique);
                        }
                        else
                        {
                            //owner not found
                            responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaOwnerNotFound);
                        }
                    }
                    else
                    {
                        //OWner Id Not Valid
                        responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaOwnerNotVaild);
                    }
                }
                else
                {
                    //unit IDnot Valid
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.IDGounaUnitNotVaild);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #5
0
        public GenericServiceContract GetContractedSales(string contratedDate)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            EntityCollection saleCollection = new EntityCollection();

            try
            {
                QueryExpression saleQuery = new QueryExpression("new_contracting");
                saleQuery.ColumnSet = new ColumnSet(new string[] { "new_name", "createdby", "createdon", "new_contractsigndate", "new_contractingstatus" });
                if (contratedDate != null && contratedDate != string.Empty)
                {
                    DateTime _contratedDate = Convert.ToDateTime(contratedDate);
                    saleQuery.Criteria.AddCondition("ohd_cancellationdate", ConditionOperator.Equal, _contratedDate);
                }
                saleQuery.Criteria.AddCondition("new_contractingstatus", ConditionOperator.Equal, 100000004);
                saleCollection = OrganizationService.RetrieveMultiple(saleQuery);
                if (saleCollection.Entities.Count > 0)
                {
                    List <Sale> saleList = new List <Sale>();
                    XElement    saleXml  = null;
                    foreach (Entity SaleEntity in saleCollection.Entities)
                    {
                        var sale = new Sale
                        {
                            SaleID       = GetAliasedValue2(SaleEntity, "new_name"),
                            CreatedBy    = GetAliasedValue2(SaleEntity, "createdby", AliasTypes.EntityReference),
                            CreatedOn    = GetAliasedValue2(SaleEntity, "createdon", AliasTypes.DateTime),
                            ContractDate = GetAliasedValue2(SaleEntity, "new_contractsigndate", AliasTypes.DateTime),
                            Status       = GetAliasedValue2(SaleEntity, "new_contractingstatus", AliasTypes.OptionSet),
                        };
                        saleList.Add(sale);
                    }
                    #region Convert Project List to Xml String
                    saleXml = new XElement("Sales", saleList.Select(x => new XElement("Sale",
                                                                                      new XElement("Name", x.SaleID),
                                                                                      new XElement("createdby", x.CreatedBy),
                                                                                      new XElement("createdon", x.CreatedOn),
                                                                                      new XElement("new_contractsigndate", x.ContractDate),
                                                                                      new XElement("new_contractingstatus", x.Status)
                                                                                      )));
                    #endregion
                    response.ResponseObject        = saleXml;
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.OK);
                }
                else
                {
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.SalesNotFound);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #6
0
        public GenericServiceContract GetAllBuildings(string createdOn)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            List <Building>  buildingList       = new List <Building>();
            EntityCollection BuildingCollection = new EntityCollection();

            try
            {
                QueryExpression buildingQuery = new QueryExpression(BuildingEntity.SchemaName);
                buildingQuery.ColumnSet = new ColumnSet(new string[] { BuildingEntity.Fields.Name, BuildingEntity.Fields.NumberOfFloors, BuildingEntity.Fields.TotalBuildingFootprint, BuildingEntity.Fields.Project, BuildingEntity.Fields.PlotNumber });
                if (createdOn != null && createdOn != string.Empty)
                {
                    DateTime CreatedOnDate = Convert.ToDateTime(createdOn);
                    buildingQuery.Criteria.AddCondition("createdon", ConditionOperator.Equal, CreatedOnDate);
                }

                BuildingCollection = OrganizationService.RetrieveMultiple(buildingQuery);
                if (BuildingCollection.Entities.Count > 0)
                {
                    XElement buildingXml = null;
                    foreach (Entity buildingEntity in BuildingCollection.Entities)
                    {
                        var building = new Building
                        {
                            Name                   = GetAliasedValue2(buildingEntity, BuildingEntity.Fields.Name),
                            Project                = GetAliasedValue2(buildingEntity, BuildingEntity.Fields.NumberOfFloors, AliasTypes.EntityReference),
                            NumberOfFloors         = GetAliasedValue2(buildingEntity, BuildingEntity.Fields.NumberOfFloors),
                            TotalBuildingFootprint = GetAliasedValue2(buildingEntity, BuildingEntity.Fields.TotalBuildingFootprint),
                            PlotNumber             = GetAliasedValue2(buildingEntity, BuildingEntity.Fields.PlotNumber),
                        };
                        buildingList.Add(building);
                    }
                    #region Convert Building List to Xml String
                    buildingXml = new XElement("Buildings", buildingList.Select(x => new XElement("Building",
                                                                                                  new XElement("Name", x.Name),
                                                                                                  new XElement("NumberOfFloors", x.NumberOfFloors),
                                                                                                  new XElement("Project", x.Project),
                                                                                                  new XElement("PlotNumber", x.PlotNumber),
                                                                                                  new XElement("TotalBuildingFootprint", x.TotalBuildingFootprint)

                                                                                                  )));
                    #endregion
                    response.ResponseObject        = buildingXml;
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.OK);
                }
                else
                {
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.buildingsNotFound);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }
コード例 #7
0
        public GenericServiceContract GetAllUnits(string createdOn)
        {
            OrganizationService = GetCrmService();
            var             response        = new GenericServiceContract();
            ResponseMessage responseMessage = new ResponseMessage();

            response.ResponseData = responseMessage;
            EntityCollection unitCollection = new EntityCollection();

            try
            {
                QueryExpression UnitQuery = new QueryExpression(UnitEntity.SchemaName);
                UnitQuery.ColumnSet = new ColumnSet(new string[] { UnitEntity.Fields.UnitID, UnitEntity.Fields.UnitNumber, UnitEntity.Fields.TotalLandAreaSqm, UnitEntity.Fields.Pricem2, UnitEntity.Fields.FloorNumber, UnitEntity.Fields.DesignType, UnitEntity.Fields.Garden, UnitEntity.Fields.GardenAreaSqm, UnitEntity.Fields.NumberofBedrooms, UnitEntity.Fields.Roof, UnitEntity.Fields.RoofAreaSqm, UnitEntity.Fields.UnitType, UnitEntity.Fields.BuiltUpArea, UnitEntity.Fields.Destination, UnitEntity.Fields.Footprint, UnitEntity.Fields.TotalBlockBuiltUpArea, UnitEntity.Fields.TotalBlockFootprint, UnitEntity.Fields.URL, UnitEntity.Fields.Building, UnitEntity.Fields.Project, UnitEntity.Fields.UnitId });
                if (createdOn != null && createdOn != string.Empty)
                {
                    DateTime CreatedOnDate = Convert.ToDateTime(createdOn);
                    UnitQuery.Criteria.AddCondition("createdon", ConditionOperator.Equal, CreatedOnDate);
                }
                unitCollection = OrganizationService.RetrieveMultiple(UnitQuery);
                if (unitCollection.Entities.Count > 0)
                {
                    XElement    unitXml  = null;
                    List <Unit> unitList = new List <Unit>();
                    foreach (Entity unitEntity in unitCollection.Entities)
                    {
                        var unit = new Unit
                        {
                            UnitID                = GetAliasedValue2(unitEntity, UnitEntity.Fields.UnitID),
                            UnitNumber            = GetAliasedValue2(unitEntity, UnitEntity.Fields.UnitNumber),
                            TotalLandAreaSqM      = GetAliasedValue2(unitEntity, UnitEntity.Fields.TotalLandAreaSqm),
                            Pricem2               = GetAliasedValue2(unitEntity, UnitEntity.Fields.Pricem2),
                            FloorNumber           = GetAliasedValue2(unitEntity, UnitEntity.Fields.FloorNumber, AliasTypes.EntityReference),
                            DesignType            = GetAliasedValue2(unitEntity, UnitEntity.Fields.DesignType, AliasTypes.EntityReference),
                            GardenAreaSqM         = GetAliasedValue2(unitEntity, UnitEntity.Fields.GardenAreaSqm),
                            Garden                = GetAliasedValue2(unitEntity, UnitEntity.Fields.Garden),
                            NumberOfBedrooms      = GetAliasedValue2(unitEntity, UnitEntity.Fields.NumberofBedrooms),
                            Roof                  = GetAliasedValue2(unitEntity, UnitEntity.Fields.Roof),
                            RoofAreaSqM           = GetAliasedValue2(unitEntity, UnitEntity.Fields.RoofAreaSqm),
                            UnitType              = GetAliasedValue2(unitEntity, UnitEntity.Fields.UnitType, AliasTypes.OptionSet),
                            BuiltUpArea           = GetAliasedValue2(unitEntity, UnitEntity.Fields.BuiltUpArea),
                            Destination           = GetAliasedValue2(unitEntity, UnitEntity.Fields.Destination, AliasTypes.EntityReference),
                            Footprint             = GetAliasedValue2(unitEntity, UnitEntity.Fields.Footprint),
                            TotalBlockBuiltUpArea = GetAliasedValue2(unitEntity, UnitEntity.Fields.TotalBlockBuiltUpArea),
                            TotalBlockFootprint   = GetAliasedValue2(unitEntity, UnitEntity.Fields.TotalBlockFootprint),
                            URL       = GetAliasedValue2(unitEntity, UnitEntity.Fields.URL),
                            Building  = GetAliasedValue2(unitEntity, UnitEntity.Fields.Building, AliasTypes.EntityReference),
                            Project   = GetAliasedValue2(unitEntity, UnitEntity.Fields.Project, AliasTypes.EntityReference),
                            UnitCRMID = GetAliasedValue2(unitEntity, UnitEntity.Fields.UnitId)
                        };
                        unitList.Add(unit);
                    }
                    #region Convert unit List to Xml String
                    unitXml = new XElement("Units", unitList.Select(x => new XElement("Unit",
                                                                                      new XAttribute("UnitCRMID", x.UnitCRMID),
                                                                                      new XElement("Name", x.UnitID),
                                                                                      new XElement("Building", x.Building),
                                                                                      new XElement("BuiltUpArea", x.BuiltUpArea),
                                                                                      new XElement("DesignType", x.DesignType),
                                                                                      new XElement("Destination", x.Destination),
                                                                                      new XElement("FloorNumber", x.FloorNumber),
                                                                                      new XElement("Footprint", x.Footprint),
                                                                                      new XElement("Garden", x.Garden),
                                                                                      new XElement("GardenAreaSqM", x.GardenAreaSqM),
                                                                                      new XElement("NumberOfBedrooms", x.NumberOfBedrooms),
                                                                                      new XElement("Pricem2", x.Pricem2),
                                                                                      new XElement("Project", x.Project),
                                                                                      new XElement("Roof", x.Roof),
                                                                                      new XElement("RoofAreaSqM", x.RoofAreaSqM),
                                                                                      new XElement("TotalBlockBuiltUpArea", x.TotalBlockBuiltUpArea),
                                                                                      new XElement("TotalBlockFootprint", x.TotalBlockFootprint),
                                                                                      new XElement("TotalLandAreaSqM", x.TotalLandAreaSqM),
                                                                                      new XElement("UnitID", x.UnitID),
                                                                                      new XElement("UnitNumber", x.UnitNumber),
                                                                                      new XElement("UnitType", x.UnitType),
                                                                                      new XElement("URL", x.URL)


                                                                                      )));
                    #endregion
                    response.ResponseObject        = unitXml;
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.OK);
                }
                else
                {
                    responseMessage.ResponseStatus = GetEnumDescription(ResponseStatus.UnitNOtFound);
                }
                response.ResponseData = responseMessage;
            }
            catch (Exception ex)
            {
                response.ResponseData.Exception = ex.Message;
                return(response);
            }
            return(response);
        }