Ejemplo n.º 1
0
        public void Get()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperProfile());
            });
            var mapper         = config.CreateMapper();
            var repositoryMock = new Mock <IBusinessRepository>();

            IBusinessService businessService = new BusinessService(repositoryMock.Object, mapper, null, null);

            Assert.Throws <ValidationException>(() => businessService.Get(1));

            repositoryMock.Setup(x => x.Get(1)).Returns(new Business());
            BusinessDto result = businessService.Get(1);

            Assert.NotNull(result);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index()
        {
            var response = new ResponseViewModel <BusinessViewModel>();
            var result   = await BusinessService.Get(RegisterViewModel.Business.Id);

            response.Status  = result.Status;
            response.Message = result.Message;
            if (result.Data != null)
            {
                response.Data = result.Data.Business;
            }
            return(View(response));
        }
        public async Task <ActionResult> Index()
        {
            var result = await BusinessService.Get(RegisterViewModel.Business.Id);

            if (result != null && result.Status)
            {
                var response = new ResponseViewModel <BusinessViewModel>();
                response.Status  = result.Status;
                response.Message = result.Message;
                response.Data    = result.Data.Business;
                return(View(response));
            }
            else
            {
                var response = this.ResponseHelper.GetResponse <BusinessViewModel>();
                return(View(Response));
            }
        }
        public async Task <ActionResult> Edit()
        {
            var response = this.ResponseHelper.GetResponse <BusinessViewModel>();

            var Memberships = await this.GetMemberships();

            ViewBag.MembershipId = Memberships.Select(s => new SelectListItem()
            {
                Value = Convert.ToString(s.Id),
                Text  = s.Title
            });

            var result = await BusinessService.Get(RegisterViewModel.Business.Id);

            if (result != null && result.Status)
            {
                response.Status  = result.Status;
                response.Message = result.Message;
                response.Data    = result.Data.Business;
            }
            return(View(response));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Index()
        {
            var result = await BusinessService.Get(RegisterViewModel.Business.Id);

            if (result != null && result.Status)
            {
                var response = new ResponseViewModel <BusinessViewModel>()
                {
                    Status  = result.Status,
                    Message = result.Message,
                    Data    = result.Data.Business
                };

                //get countries and set to dropdown list
                var Countries = await this.GetCountries();

                ViewBag.CountryId = Countries.Select(s => new SelectListItem()
                {
                    Value = Convert.ToString(s.Id),
                    Text  = s.Name
                });

                //get timezones and set to dropdown list
                var Timezones = await this.GetTimeZone();

                ViewBag.TimezoneId = Timezones.Select(s => new SelectListItem()
                {
                    Value = Convert.ToString(s.Id),
                    Text  = s.Title
                });

                //get business category and set to dropdown list
                var businessCategories = await this.GetBusinessCategories();

                var parentCategories = businessCategories.ToDictionary(d => d.Id, d => d.Name);
                var groupCategories  = businessCategories.Select(s => s.Name).Select(ss => new SelectListGroup()
                {
                    Name = ss
                }).ToList();

                var childCategories = (from c in businessCategories
                                       join p in businessCategories
                                       on c.ParentId equals p.Id
                                       select new
                {
                    Id = c.Id,
                    Text = c.Name,
                    ParentId = c.ParentId
                }).ToList();

                var groupedData = childCategories
                                  .Where(f => f.ParentId != 0)
                                  .Select(x => new SelectListItem
                {
                    Value = x.Id.ToString(),
                    Text  = x.Text,
                    Group = groupCategories.First(a => a.Name == parentCategories[x.ParentId.Value])
                }).ToList();

                ViewBag.BusinessCategoryId = groupedData;

                return(View(response));
            }
            else
            {
                var response = this.ResponseHelper.GetResponse <BusinessViewModel>();
                return(View(Response));
            }
        }
Ejemplo n.º 6
0
 public ActionResult <List <Business> > Get() =>
 _businessService.Get();
Ejemplo n.º 7
0
        protected override void OnPreRender(EventArgs e)
        {
            if (null == entity)
            {
                return;
            }

            string root = ("/" == Request.ApplicationPath) ? "" : Request.ApplicationPath;

            int contactIndex  = 0;
            int instanceIndex = 0;

            EntityBase rootEntity = null;

            if (entity is BusinessEntity)
            {
                rootEntity = entity;

                if (-1 != elementIndex)
                {
                    key = ((BusinessEntity)entity).BusinessKey + ":" + elementIndex;
                }
                else
                {
                    key = ((BusinessEntity)entity).BusinessKey;
                }
            }
            else if (entity is TModel)
            {
                rootEntity = entity;
                key        = ((TModel)entity).TModelKey;
            }
            else if (entity is BusinessService)
            {
                BusinessEntity  business = new BusinessEntity();
                BusinessService service  = (BusinessService)entity;

                key = service.ServiceKey;

                business.BusinessKey = service.BusinessKey;
                business.Get();

                rootEntity = business;
            }
            else if (entity is BindingTemplate)
            {
                BusinessEntity  business = new BusinessEntity();
                BusinessService service  = new BusinessService();
                BindingTemplate binding  = (BindingTemplate)entity;

                if (-1 != elementIndex)
                {
                    key = binding.BindingKey + ":" + elementIndex;
                }
                else
                {
                    key = binding.BindingKey;
                }

                service.ServiceKey = binding.ServiceKey;
                service.Get();

                business.BusinessKey = service.BusinessKey;
                business.Get();

                rootEntity = business;
            }

            //
            // Setup explorer information section.
            //
            if (rootEntity is BusinessEntity)
            {
                BusinessEntity business = rootEntity as BusinessEntity;

                //
                // Build explorer tree.
                //
                TreeNode businessNode = tree.Nodes.Add(
                    business.Names[0].Value,
                    business.BusinessKey,
                    "../images/business.gif");

                businessNode.OnClick = "Entity_OnSelect( [[node]], '../details/businessdetail.aspx?key=" + business.BusinessKey + Iff(frames, "&frames=true", "") + "' )";
                businessNode.Tooltip = Localization.GetString("TOOLTIP_SEARCH_PROVIDER");

                if (key == business.BusinessKey)
                {
                    businessNode.Select();
                }


                contactIndex = 0;

                foreach (Contact contact in business.Contacts)
                {
                    TreeNode contactNode = businessNode.Nodes.Add(
                        contact.PersonName,
                        business.BusinessKey + ":" + contactIndex,
                        "../images/contact.gif");

                    contactNode.OnClick = "Entity_OnSelect( [[node]], '../details/contactdetail.aspx?key=" + business.BusinessKey + "&index=" + contactIndex + Iff(frames, "&frames=true", "") + "' )";
                    contactNode.Tooltip = Localization.GetString("TOOLTIP_SEARCH_CONTACT");

                    if (key == business.BusinessKey + ":" + contactIndex)
                    {
                        contactNode.Select();
                    }

                    contactIndex++;
                }

                //sort the services
                business.BusinessServices.Sort();

                foreach (BusinessService service in business.BusinessServices)
                {
                    if (service.BusinessKey.ToLower() != business.BusinessKey.ToLower())
                    {
                        //
                        // Added logic to catch errors on this.
                        // if the refrenced service doesn't exist,
                        // then we can't get the name, thus we get
                        // an error.
                        //

                        TreeNode nodeService;

                        //
                        // if there are names, then the service projections still exists,
                        // use the first name in teh collection.
                        // otherwise leave name as the broken projection string.
                        //
                        if (service.Names.Count > 0)
                        {
                            nodeService = businessNode.Nodes.Add(
                                service.Names[0].Value,
                                service.ServiceKey,
                                "../images/service_projection.gif");

                            nodeService.OnClick = "Entity_OnSelect( [[node]], '../details/servicedetail.aspx?key=" + service.ServiceKey + Iff(frames, "&frames=true", "") + "&projectionKey=" + business.BusinessKey + "' )";
                            nodeService.Tooltip = Localization.GetString("TOOLTIP_SEARCH_SERVICEPROJECTION");
                        }
                        else
                        {
                            nodeService = businessNode.Nodes.Add(
                                Localization.GetString("BUTTON_PROJECTIONBROKEN"),
                                service.ServiceKey,
                                "../images/x.gif");

                            nodeService.OnClick = "javascript:alert('" + Localization.GetString("TOOLTIP_PROJECTIONBROKEN") + "');";
                            nodeService.Tooltip = Localization.GetString("TOOLTIP_PROJECTIONBROKEN");
                        }
                    }
                    else
                    {
                        TreeNode serviceNode = businessNode.Nodes.Add(
                            service.Names[0].Value,
                            service.ServiceKey,
                            "../images/service.gif");

                        serviceNode.OnClick = "Entity_OnSelect( [[node]], '../details/servicedetail.aspx?key=" + service.ServiceKey + Iff(frames, "&frames=true", "") + "' )";
                        serviceNode.Tooltip = Localization.GetString("TOOLTIP_SEARCH_SERVICE");

                        if (key == service.ServiceKey)
                        {
                            serviceNode.Select();
                        }

                        int bindingCount = 0;
                        foreach (BindingTemplate binding in service.BindingTemplates)
                        {
                            bindingCount++;

                            TreeNode bindingNode = serviceNode.Nodes.Add(
                                UDDI.Utility.StringEmpty(binding.AccessPoint.Value)
                                                                ? Localization.GetString("HEADING_NONE")
                                                                : binding.AccessPoint.Value,
                                binding.BindingKey,
                                "../images/binding.gif");

                            bindingNode.OnClick = "Entity_OnSelect( [[node]], '../details/bindingdetail.aspx?key=" + binding.BindingKey + Iff(frames, "&frames=true", "") + "' )";
                            bindingNode.Tooltip = Localization.GetString("TOOLTIP_SEARCH_BINDING");

                            if (key == binding.BindingKey)
                            {
                                bindingNode.Select();
                            }

                            instanceIndex = 0;
                            foreach (TModelInstanceInfo instance in binding.TModelInstanceInfos)
                            {
                                TreeNode instanceNode = bindingNode.Nodes.Add(
                                    UDDI.Utility.StringEmpty(instance.TModelKey)
                                                                        ? Localization.GetString("HEADING_NONE")
                                                                        : Lookup.TModelName(instance.TModelKey),
                                    binding.BindingKey + ":" + instanceIndex,
                                    "../images/instance.gif");

                                instanceNode.OnClick = "Entity_OnSelect( [[node]], '../details/instanceinfodetail.aspx?key=" + binding.BindingKey + "&index=" + instanceIndex + Iff(frames, "&frames=true", "") + "' )";
                                instanceNode.Tooltip = Localization.GetString("TOOLTIP_SEARCH_INSTANCE_INFO");

                                if (key == binding.BindingKey + ":" + instanceIndex)
                                {
                                    instanceNode.Select();
                                }

                                instanceIndex++;
                            }
                        }
                    }
                }
            }
            else if (rootEntity is TModel)
            {
                TModel tModel = rootEntity as TModel;

                //
                // Build explorer tree.
                //
                TreeNode nodeTModel = tree.Nodes.Add(
                    tModel.Name,
                    tModel.TModelKey,
                    "../images/tmodel.gif");

                nodeTModel.OnClick = "Entity_OnSelect( [[node]], '../details/modeldetail.aspx?key=" + Conversions.GuidStringFromKey(tModel.TModelKey) + Iff(frames, "&frames=true", "") + "' )";
                nodeTModel.Tooltip = Localization.GetString("TOOLTIP_SEARCH_TMODEL");
                nodeTModel.Select();
            }
            else
            {
                Debug.Assert(false, "Unknown root entity '" + rootEntity.ToString() + "'.");
            }

            if (null != tree.SelectedNode)
            {
                tree.SelectedNode.EnsureVisible();
                tree.SelectedNode.Expand();
            }
        }