Пример #1
0
        public void Update(AbstractInfo entity)
        {
            var abstractInfo = unitOfWork.AbstractInfoRepo.GetById(entity.Id);

            abstractInfo.Text = entity.Text;
            unitOfWork.Save();
        }
Пример #2
0
        public static T[] CreateItems <T>(string[] alternatingNames, int count, string objectType = null, Action <T, string> initializer = null) where T : AbstractInfo <T>, new()
        {
            if ((alternatingNames == null) || (alternatingNames.Length == 0))
            {
                throw new ArgumentException("Parameter must be a non-empty instance of array.", nameof(alternatingNames));
            }

            if (alternatingNames.Length > count)
            {
                throw new ArgumentException($"Length of '{nameof(alternatingNames)}' must be equal or greater than a value of '{nameof(count)}'");
            }

            int namesLength = alternatingNames.Length;
            int iterations  = count / namesLength;

            var items = new List <T>();

            for (int i = 0; i < namesLength; i++)
            {
                int upperBound = (i == 0) ? iterations + (count % namesLength) : iterations;
                for (int j = 0; j < upperBound; j++)
                {
                    string newObjectName = alternatingNames[i] + j;
                    var    item          = AbstractInfo <T> .New((info) =>
                    {
                        initializer?.Invoke(info, newObjectName);
                        info[info.TypeInfo.DisplayNameColumn] = newObjectName;
                    }, objectType);

                    items.Add(item);
                }
            }

            return(items.ToArray());
        }
Пример #3
0
        public IActionResult Contacts()
        {
            AbstractInfo info = null;

            if (abstractInfoManager.GetAll().Count() < 1)
            {
                info = new AbstractInfo()
                {
                    Title = "по умолчанию", Text = "09826259810"
                };
            }
            else
            {
                info = abstractInfoManager.Get().LastOrDefault();
            }
            return(View(new StartPageViewModel()
            {
                Info = info
            }));
        }
Пример #4
0
        public IActionResult Index()
        {
            if (!imageManager.GetAll().Any())
            {
                imageManager.Insert(new Image()
                {
                    ImagePath = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg"
                });
                imageManager.Insert(new Image()
                {
                    ImagePath = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg"
                });
            }
            if (!carouselManager.GetAll().Any())
            {
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
                carouselManager.Insert(new Carousel()
                {
                    ImageMin = "http://lavenderhillhigh.co.za/wp-content/gallery/fundraising/default-image.jpg", Text = "Default text", Image_Id = 1
                });
            }
            while (projectsManager.GetAll().Count() < 3)
            {
                projectsManager.Insert(new Projects()
                {
                    Image_Id = 1, Title = "Default text"
                });
            }

            if (!faceBookManager.GetAll().Any())
            {
                faceBookManager.Insert(new FaceBook()
                {
                    FBPost = "Default text", Date = DateTime.Now, Image_Id = 1, PersonLink = "#", PersonName = "Default Name"
                });
            }
            while (videoManager.GetAll().Count() < 4)
            {
                videoManager.Insert(new Video()
                {
                    Text      = "Default Text",
                    VideoFile = "<iframe width=\"854\" height=\"480\" src=\"https://www.youtube.com/embed/TFHcJMzgYiE\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>",
                    Day       = DateTime.Today.Day,
                    Month     = ((MonthEnum)DateTime.Today.Month - 1).ToString(),
                    Year      = DateTime.Today.Year
                });
            }


            List <FaceBook> fbLst;

            if (faceBookManager.GetAll().Count() > 5)
            {
                fbLst = faceBookManager.Get().Reverse().Take(5).ToList();
            }
            else
            {
                fbLst = faceBookManager.GetAll().ToList();
            }

            var carouselLst = carouselManager.GetAll().ToList();

            News[] news = newsManager.GetAll().ToArray();


            for (int i = 0; i < newsManager.GetAll().Count(); i++)//construction to sort dates
            {
                for (int i2 = i + 1; i2 < newsManager.GetAll().Count(); i2++)
                {
                    DateTime date1 = new DateTime();
                    DateTime date2 = new DateTime();
                    News     temp  = null;
                    foreach (MonthEnum item in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i].Month == item.ToString())
                        {
                            date1 = new DateTime(news[i].Year, (int)item + 1, news[i].Day);
                            break;
                        }
                    }

                    foreach (MonthEnum item2 in Enum.GetValues(typeof(MonthEnum)))
                    {
                        if (news[i2].Month == item2.ToString())
                        {
                            date2 = new DateTime(news[i2].Year, (int)item2 + 1, news[i2].Day);
                            break;
                        }
                    }

                    if (DateTime.Compare(date1, date2) < 0)
                    {
                        temp     = news[i];
                        news[i]  = news[i2];
                        news[i2] = temp;
                    }
                    else
                    {
                        break;
                    }
                }
            }


            List <News> newsLst;

            if (newsManager.GetAll().Count() > 8)
            {
                newsLst = news.Take(8).ToList();
            }
            else
            {
                newsLst = news.ToList();
            }

            var          projLst     = projectsManager.GetAll().ToList();
            var          partnersLst = partnersManager.GetAll().ToList();
            var          videoLst    = videoManager.GetAll().ToList();
            var          imgLst      = imageManager.GetAll().ToList();
            var          mediaLst    = mediaManager.GetAll().ToList();
            AbstractInfo info        = null;

            if (abstractInfoManager.GetAll().Count() < 1)
            {
                info = new AbstractInfo()
                {
                    Title = "по умолчанию", Text = "09826259810"
                };
            }
            else
            {
                info = abstractInfoManager.Get().LastOrDefault();
            }

            return(View(new StartPageViewModel()
            {
                CarouselLst = carouselLst,
                FaceBookLst = fbLst,
                ProjectsLst = projLst,
                VideoLst = videoLst,
                NewsLst = newsLst,
                ImagesLst = imgLst,
                PartnersLst = partnersLst,
                MediaLst = mediaLst,
                Info = info
            }));
        }
Пример #5
0
        public static List <WeixinCardModel> GetWeixinCardModelList(int pkid = -1)
        {
            List <WeixinCardModel> list = new List <WeixinCardModel>();
            var dt = DALWeiXinCard.GetWeiXinCardList(pkid);

            try
            {
                if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        var dateinfo = new DateInfo()
                        {
                            begin_time       = Convert.IsDBNull(row["begin_time"]) ? new DateTime(1970, 1, 1) : Convert.ToDateTime(row["begin_time"]),
                            end_time         = Convert.IsDBNull(row["end_time"]) ? new DateTime(1970, 1, 1) : Convert.ToDateTime(row["end_time"]),
                            begin_timestamp  = Convert.IsDBNull(row["begin_timestamp"]) ? null : (ulong?)Convert.ToUInt64(row["begin_timestamp"]),
                            end_timestamp    = Convert.IsDBNull(row["end_timestamp"]) ? null : (ulong?)Convert.ToUInt64(row["end_timestamp"]),
                            fixed_begin_term = Convert.IsDBNull(row["fixed_begin_term"]) ? null : (Int32?)Convert.ToInt32(row["fixed_begin_term"]),
                            fixed_term       = Convert.IsDBNull(row["fixed_term"]) ? null : (Int32?)Convert.ToInt32(row["fixed_term"]),
                            // type=(TimeType)Enum.Parse(typeof(TimeType),row["type"].ToString())
                            type = Convert.IsDBNull(row["type"]) ? null : row["type"].ToString()
                        };
                        var skuobj = new SKUQuantity()
                        {
                            quantity = Convert.IsDBNull(row["quantity"]) ? null : (Int32?)Convert.ToInt32(row["quantity"])
                        };
                        var baseinfo = new WeixinCardBaseInfo()
                        {
                            title                   = Convert.IsDBNull(row["title"]) ? null : row["title"].ToString(),
                            colorid                 = Convert.IsDBNull(row["color"]) ? 1 : Colors.Where(q => q.ColorValue == row["color"].ToString()).FirstOrDefault() != null?Colors.Where(q => q.ColorValue == row["color"].ToString()).First().ColorIndex : 2,
                            notice                  = Convert.IsDBNull(row["notice"]) ? null                                                                                                                                                                 : row["notice"].ToString(),
                            description             = Convert.IsDBNull(row["description"]) ? null                                                                                                                                                            : row["description"].ToString(),
                            supplierId              = Convert.IsDBNull(row["supplierId"]) ? 1                                                                                                                                                                : (Int32?)Convert.ToInt32(row["supplierId"]),
                            center_title            = Convert.IsDBNull(row["center_title"]) ? null                                                                                                                                                           : row["center_title"].ToString(),
                            center_sub_title        = Convert.IsDBNull(row["center_sub_title"]) ? null                                                                                                                                                       : row["center_sub_title"].ToString(),
                            center_url              = Convert.IsDBNull(row["center_url"]) ? null                                                                                                                                                             : row["center_url"].ToString(),
                            custom_url              = Convert.IsDBNull(row["custom_url"]) ? null                                                                                                                                                             : row["custom_url"].ToString(),
                            custom_url_name         = Convert.IsDBNull(row["custom_url_name"]) ? null                                                                                                                                                        : row["custom_url_name"].ToString(),
                            custom_url_sub_title    = Convert.IsDBNull(row["custom_url_sub_title"]) ? null                                                                                                                                                   : row["custom_url_sub_title"].ToString(),
                            promotion_url           = Convert.IsDBNull(row["promotion_url"]) ? null                                                                                                                                                          : row["promotion_url"].ToString(),
                            promotion_url_name      = Convert.IsDBNull(row["promotion_url_name"]) ? null                                                                                                                                                     : row["promotion_url_name"].ToString(),
                            promotion_url_sub_title = Convert.IsDBNull(row["promotion_url_sub_title"]) ? null                                                                                                                                                : row["promotion_url_sub_title"].ToString(),
                            service_phone           = Convert.IsDBNull(row["service_phone"]) ? null                                                                                                                                                          : row["service_phone"].ToString(),
                            get_limit               = Convert.IsDBNull(row["get_limit"]) ? null                                                                                                                                                              : (Int32?)Convert.ToInt32(row["get_limit"]),
                            use_limit               = Convert.IsDBNull(row["use_limit"]) ? null                                                                                                                                                              : (Int32?)Convert.ToInt32(row["use_limit"]),
                            can_share               = Convert.IsDBNull(row["can_share"]) ? false                                                                                                                                                             : Convert.ToBoolean(row["can_share"]),
                            can_give_friend         = Convert.IsDBNull(row["can_give_friend"]) ? false                                                                                                                                                       : Convert.ToBoolean(row["can_give_friend"]),
                            use_all_locations       = Convert.IsDBNull(row["use_all_locations"]) ? false                                                                                                                                                     : Convert.ToBoolean(row["use_all_locations"]),
                            // location_id_list= row["location_id_list"].ToString(),
                            source               = Convert.IsDBNull(row["source"]) ? null               : row["source"].ToString(),
                            use_custom_code      = Convert.IsDBNull(row["use_custom_code"]) ? false     : Convert.ToBoolean(row["use_custom_code"]),
                            get_custom_code_mode = Convert.IsDBNull(row["get_custom_code_mode"]) ? null : row["get_custom_code_mode"].ToString(),
                            bind_openid          = Convert.IsDBNull(row["bind_openid"]) ? false         : Convert.ToBoolean(row["bind_openid"]),
                            sku       = skuobj,
                            date_info = dateinfo
                        };
                        var usecondition = new ConditionalUse()
                        {
                            accept_category             = Convert.IsDBNull(row["accept_category"]) ? null : row["accept_category"].ToString(),
                            reject_category             = Convert.IsDBNull(row["reject_category"]) ? null : row["accept_category"].ToString(),
                            least_cost                  = Convert.IsDBNull(row["use_condition_least_cost"]) ? null : (Int32?)Convert.ToInt32(row["use_condition_least_cost"]),
                            object_use_for              = Convert.IsDBNull(row["object_use_for"]) ? null : row["object_use_for"].ToString(),
                            can_use_with_other_discount = Convert.IsDBNull(row["can_use_with_other_discount"]) ? false : Convert.ToBoolean(row["can_use_with_other_discount"])
                        };
                        var              icon_url_list = Convert.IsDBNull(row["icon_url_list"]) ? string.Empty : row["icon_url_list"].ToString();
                        List <string>    icons         = icon_url_list.Split(new char[] { ';' }).Where(q => q != null).ToList();
                        var              imagetextstr  = Convert.IsDBNull(row["text_image_list"]) ? string.Empty : row["text_image_list"].ToString();
                        List <ImageText> imageTextList = JsonConvert.DeserializeObject <List <ImageText> >(imagetextstr);


                        var abstractinfo = new AbstractInfo();

                        abstractinfo.abstractstr = Convert.IsDBNull(row["abstract"]) ? null : row["abstract"].ToString();
                        if (icons != null && icons.Any())
                        {
                            icons = icons.Where(q => !string.IsNullOrWhiteSpace(q)).ToList();
                            if (icons.Count() == 5)
                            {
                                abstractinfo.icon1 = icons[0];
                                abstractinfo.icon2 = icons[1];
                                abstractinfo.icon3 = icons[2];
                                abstractinfo.icon4 = icons[3];
                                abstractinfo.icon5 = icons[4];
                            }
                            else if (icons.Count() == 4)
                            {
                                abstractinfo.icon1 = icons[0];
                                abstractinfo.icon2 = icons[1];
                                abstractinfo.icon3 = icons[2];
                                abstractinfo.icon4 = icons[3];
                            }
                            else if (icons.Count() == 3)
                            {
                                abstractinfo.icon1 = icons[0];
                                abstractinfo.icon2 = icons[1];
                                abstractinfo.icon3 = icons[2];
                            }
                            else if (icons.Count() == 2)
                            {
                                abstractinfo.icon1 = icons[0];
                                abstractinfo.icon2 = icons[1];
                            }
                            else if (icons.Count() == 1)
                            {
                                abstractinfo.icon1 = icons[0];
                            }
                        }
                        if (imageTextList != null && imageTextList.Any())
                        {
                            imageTextList = imageTextList.Where(q => q != null).ToList();
                            if (imageTextList.Count() == 5)
                            {
                                abstractinfo.imageText1 = imageTextList[0];
                                abstractinfo.imageText2 = imageTextList[1];
                                abstractinfo.imageText3 = imageTextList[2];
                                abstractinfo.imageText4 = imageTextList[3];
                                abstractinfo.imageText5 = imageTextList[4];
                            }
                            else if (imageTextList.Count() == 4)
                            {
                                abstractinfo.imageText1 = imageTextList[0];
                                abstractinfo.imageText2 = imageTextList[1];
                                abstractinfo.imageText3 = imageTextList[2];
                                abstractinfo.imageText4 = imageTextList[3];
                            }
                            else if (imageTextList.Count() == 3)
                            {
                                abstractinfo.imageText1 = imageTextList[0];
                                abstractinfo.imageText2 = imageTextList[1];
                                abstractinfo.imageText3 = imageTextList[2];
                            }
                            else if (imageTextList.Count() == 2)
                            {
                                abstractinfo.imageText1 = imageTextList[0];
                                abstractinfo.imageText2 = imageTextList[1];
                            }
                            else if (imageTextList.Count() == 1)
                            {
                                abstractinfo.imageText1 = imageTextList[0];
                            }
                        }


                        var advancedinfo = new WeixinCardAdvancedInfo()
                        {
                            abstractinfo  = abstractinfo,
                            use_condition = usecondition
                        };
                        var totalinfo = new WeixinCardTotalModel()
                        {
                            deal_detail    = Convert.IsDBNull(row["deal_detail"]) ? null : row["deal_detail"].ToString(),
                            least_cost     = Convert.IsDBNull(row["least_cost"]) ? null : (Int32?)Convert.ToInt32(row["least_cost"]),
                            reduce_cost    = Convert.IsDBNull(row["reduce_cost"]) ? null : (Int32?)Convert.ToInt32(row["reduce_cost"]),
                            discount       = Convert.IsDBNull(row["discount"]) ? null : (Int32?)Convert.ToInt32(row["discount"]),
                            gift           = Convert.IsDBNull(row["gift"]) ? null : row["gift"].ToString(),
                            default_detail = Convert.IsDBNull(row["default_detail"]) ? null : row["default_detail"].ToString(),
                            base_info      = baseinfo,
                            advanced_info  = advancedinfo
                        };
                        var model = new WeixinCardModel()
                        {
                            total_info  = totalinfo,
                            card_id     = Convert.IsDBNull(row["card_id"]) ? null : row["card_id"].ToString(),
                            PKID        = Convert.IsDBNull(row["PKID"]) ? null : (Int32?)Convert.ToInt32(row["PKID"]),
                            PushedCount = Convert.IsDBNull(row["PushedCount"]) ? null : (Int32?)Convert.ToInt32(row["PushedCount"]),
                            card_type   = (CardTypeEnum)Enum.Parse(typeof(CardTypeEnum), row["card_type"].ToString())
                        };
                        list.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(list);
        }
Пример #6
0
        public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info)
        {
            if (!strategy.IncludeInfoStrategyForMvcContextInfo.Include)
            {
                return;
            }

            var httpContext = HttpContext.Current;

            if (httpContext != null)
            {
                var mvcContextInfo = new MvcContextInfo();
                ControllerContext controllerContext = null;
                var isMvcApp = false;
                var actionExecutedContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey]
                                            as ActionExecutedContext;
                if (actionExecutedContext != null)
                {
                    isMvcApp = true;
                    mvcContextInfo.ControllerName = actionExecutedContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                    mvcContextInfo.ActionName     = actionExecutedContext.ActionDescriptor.ActionName;
                    if (actionExecutedContext.Result != null)
                    {
                        mvcContextInfo.ActionResultType = actionExecutedContext.Result.ToString();
                    }

                    if (actionExecutedContext.Controller != null)
                    {
                        controllerContext = actionExecutedContext.Controller.ControllerContext;
                    }

                    mvcContextInfo.State = MvcActionStage.ActionExecuted;
                }

                var actionExecutingContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey]
                                             as ActionExecutingContext;
                if (actionExecutingContext != null)
                {
                    isMvcApp = true;
                    if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeParameterData)
                    {
                        var parameterData = new Dictionary <string, string>();
                        foreach (var key in actionExecutingContext.ActionParameters.Keys)
                        {
                            parameterData.Add(key, (actionExecutingContext.ActionParameters[key] ?? "").ToString());
                        }
                        mvcContextInfo.ParameterData = parameterData;
                    }

                    mvcContextInfo.ControllerName = actionExecutingContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                    mvcContextInfo.ActionName     = actionExecutingContext.ActionDescriptor.ActionName;
                    if (actionExecutingContext.Result != null)
                    {
                        mvcContextInfo.ActionResultType = actionExecutingContext.Result.ToString();
                    }

                    if (actionExecutingContext.Controller != null)
                    {
                        controllerContext = actionExecutingContext.Controller.ControllerContext;
                    }

                    mvcContextInfo.State = MvcActionStage.ActionExecuting;
                }

                var resultExecutedContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey]
                                            as ResultExecutedContext;
                if (resultExecutedContext != null)
                {
                    isMvcApp = true;
                    if (resultExecutedContext.Result != null)
                    {
                        mvcContextInfo.ActionResultType = resultExecutedContext.Result.ToString();
                    }

                    if (resultExecutedContext.Controller != null)
                    {
                        controllerContext = resultExecutedContext.Controller.ControllerContext;
                    }

                    mvcContextInfo.State = MvcActionStage.ResultExecuted;
                }

                var resultExecutingContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey]
                                             as ResultExecutingContext;
                if (resultExecutingContext != null)
                {
                    isMvcApp = true;
                    if (actionExecutedContext.Result != null)
                    {
                        mvcContextInfo.ActionResultType = resultExecutingContext.Result.ToString();
                    }

                    if (resultExecutingContext.Controller != null)
                    {
                        controllerContext = resultExecutingContext.Controller.ControllerContext;
                    }

                    mvcContextInfo.State = MvcActionStage.ResultExecuting;
                }

                if (controllerContext != null)
                {
                    mvcContextInfo.IsChildAction = controllerContext.IsChildAction;

                    if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeViewData)
                    {
                        var viewData = new Dictionary <string, string>();
                        foreach (var key in controllerContext.Controller.ViewData.Keys)
                        {
                            viewData.Add(key, (controllerContext.Controller.ViewData[key] ?? "").ToString());
                        }
                        mvcContextInfo.ViewData = viewData;
                    }

                    if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeRouteData)
                    {
                        var routeData = new Dictionary <string, string>();
                        foreach (var key in controllerContext.RouteData.Values.Keys)
                        {
                            routeData.Add(key, (controllerContext.RouteData.Values[key] ?? "").ToString());
                        }
                        mvcContextInfo.RouteData = routeData;
                    }

                    if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeTempData)
                    {
                        var tempData = new Dictionary <string, string>();
                        foreach (var key in controllerContext.Controller.TempData.Keys)
                        {
                            tempData.Add(key, (controllerContext.Controller.TempData[key] ?? "").ToString());
                        }
                        mvcContextInfo.TempData = tempData;
                    }
                }

                if (isMvcApp)
                {
                    info.MvcContextInfo = mvcContextInfo;
                }
            }
        }
Пример #7
0
 public void Delete(AbstractInfo entityToDelete)
 {
     unitOfWork.AbstractInfoRepo.Delete(entityToDelete);
     unitOfWork.Save();
 }
Пример #8
0
 public void Insert(AbstractInfo entity)
 {
     unitOfWork.AbstractInfoRepo.Insert(entity);
     unitOfWork.Save();
 }