public object GetProperty(string property, PymePropertyListing info1)
        {
            try
            {
                switch (info1)
                {
                case PymePropertyListing.Info:
                    var info          = _pymeManager.GetInfo(TenantId);
                    var propertyValue = info.GetType().GetProperty(property).GetValue(info);
                    return(string.IsNullOrEmpty(propertyValue.ToString()) ? $"No se ha encontrado un valor para la propiedad {property} <a href='/Admin/MainMenu/'>Reparar</a>" : propertyValue);

                case PymePropertyListing.Contact:
                    var contactInfo = _pymeManager.GetContactInfo(TenantId);
                    var propertyContactInfoValue = contactInfo.GetType().GetProperty(property).GetValue(contactInfo);
                    return(propertyContactInfoValue);

                case PymePropertyListing.ContentSections:
                    var result = _pymeManager.GetMainPageContent(property, TenantId);
                    return(result);

                default:
                    throw new ArgumentOutOfRangeException(nameof(info1), info1, null);
                }
            }
            catch (Exception)
            {
                return($"No se ha encontrado la propiedad {property} <a href='/Admin/MainMenu/'>Reparar</a>");
            }
        }
Beispiel #2
0
        public int AddInfo(PymeInfoInput input)
        {
            Pyme.Entities.PymeInfo info;
            if (input.Id != 0)
            {
                var infoDb = _pymeManager.GetInfo(TenantId);
                info = input.MapTo(infoDb);
            }
            else
            {
                info = input.MapTo <Pyme.Entities.PymeInfo>();
            }
            if (input.Image.ContentLength > 0)
            {
                var formatedFolder = string.Format(ImageFolder, TenantHelper.TenantId);
                var image          = _imageManager.SaveImage(null, null, input.Image, formatedFolder);
                info.PymeLogo = image;
            }
            var id = _pymeManager.AddInfo(info);

            return(id);
        }