Exemple #1
0
        public async Task <ActionResult> Create([Bind(Include = "ImageUpload,width,height,name,item_type_id")] LayoutViewModel model)
        {
            var                context         = HttpContext;
            string             file            = HttpContext.Request.Form["ImageUpload"];
            HttpPostedFileBase f               = HttpContext.Request.Files[file];
            var                validImageTypes = new string[]
            {
                "image/jpeg",
                "image/png"
            };

            if (model.ImageUpload == null || model.ImageUpload.ContentLength == 0)
            {
                ModelState.AddModelError("ImageUpload", "This field is required");
            }
            else if (!validImageTypes.Contains(model.ImageUpload.ContentType))
            {
                ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image.");
            }
            if (ModelState.IsValid)
            {
                var uploadDir = "~/Files";
                var imagePath = Path.Combine(Server.MapPath(uploadDir), model.ImageUpload.FileName);
                var imageUrl  = Path.Combine(uploadDir, model.ImageUpload.FileName);
                model.ImageUpload.SaveAs(imagePath);
                model.layout.Image = imageUrl;
                db.layout.Add(model.layout);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ITEM_TYPE_ID = new SelectList(db.ITEM_TYPE, "Id", "NAME", model.layout.ITEM_TYPE_ID);
            return(View(model));
        }
Exemple #2
0
        public IActionResult _Layout()
        {
            LayoutViewModel viewModel = new LayoutViewModel();

            //viewModel.InvitesCounter = _showReviewLogic.CountInvitesOfUser(1); //UserId van cookie
            return(View(viewModel));
        }
Exemple #3
0
        public BaseController()
        {
            var model = new LayoutViewModel();

            model.HeaderCategories = DbContext.Categories.ToList();
            this.BaseModel         = model;
        }
Exemple #4
0
        protected override DriverResult Editor(LayoutTemplatePart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var model = new LayoutViewModel {
                Layout = part
            };
            var oldLayoutId = part.ParentLayoutId ?? -1;

            updater.TryUpdateModel(model, Prefix, null, null);
            if (model.ParentLayoutId != null && model.ParentLayoutId != 0)
            {
                var parentLayout = _contentManager.Get <LayoutTemplatePart>(model.ParentLayoutId.Value);
                model.Layout.ParentLayoutId = parentLayout.Id;
            }
            var descriptionDocument  = part.LayoutDescriptionDocument;
            var layoutElement        = descriptionDocument.Element("layout");
            var parentLayoutRecordId = model.Layout.ParentLayoutId ?? -1;

            if (layoutElement == null)
            {
                updater.AddModelError(
                    Prefix,
                    T("Layout description document should have layout as its top-level element."));
            }
            else if ((!layoutElement.Elements().Any() && model.ParentLayoutId != null) ||
                     (oldLayoutId != parentLayoutRecordId && model.Layout.ParentLayoutId != null))
            {
                var parentLayout = _contentManager.Get <LayoutTemplatePart>(model.ParentLayoutId.Value);
                model.Layout.LayoutDescription = parentLayout != null ? parentLayout.LayoutDescription : default(string);
            }

            return(Editor(part, shapeHelper));
        }
Exemple #5
0
        public ActionResult Index(string ReturnUrl, string module)
        {
            if (ReturnUrl != null && ReturnUrl.Contains("Quotes/QuoteMobileApprove"))
            {
                return(Redirect(ReturnUrl));
            }

            if (User.Identity.IsAuthenticated)
            {
                if (ReturnUrl != null)
                {
                    return(RedirectToLocal(ReturnUrl));
                }

                var userId = User.Identity.GetUserId();
                var model  = new LayoutViewModel();


                return(View("_index", model));
            }
            else
            {
                return(RedirectToAction("authUser", "home", new { ReturnUrl = ReturnUrl }));
            }
        }
        public ActionResult Home()
        {
            if (User.Identity.IsAuthenticated)
            {
                ApplicationUserManager _userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                string        id      = User.Identity.GetUserId();
                UsuarioHelper UHelper = new UsuarioHelper(_userManager, id);

                if (!UHelper.isAdmin)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(RedirectToAction("Index", "Admin"));
                }
            }

            SharedEntities.Entities.Configuracion conf = WebApiConfig.BuilderService(null).getConfiguracion(1);

            LayoutViewModel model = new LayoutViewModel();

            model.Configuracion = conf;

            return(View(model));
        }
        protected override void OnException(ExceptionContext filterContext)
        {
            filterContext.ExceptionHandled = true;
            string error;

            if (filterContext.Exception is KnownException)
            {
                error = filterContext.Exception.Message;
            }
            else
            {
                if (Request.QueryString["debug"] == SettingContext.Instance.DebugKey)
                {
                    error = filterContext.Exception.GetAllMessages();
                }
                else
                {
                    error = "服务器未知错误,请重试。如果该问题一直存在,请联系管理员。感谢您的支持。";
                }
            }
            if (Request.QueryString["ajax"] == "true")
            {
                var result = new StandardJsonResult();
                result.Fail(error);
                filterContext.Result = result;
            }
            else
            {
                var model = new LayoutViewModel();
                model.Error          = error;
                filterContext.Result = this.View(this.GetErrorViewPath(), model);
            }
        }
Exemple #8
0
        public LayoutViewModel CreateViewModelByType(string ownerId, string type)
        {
            var viewModel = new LayoutViewModel();

            switch (type)
            {
            case "Logo":
                viewModel.LogoConfig = _siteConfigService.GetConfigsByTypeAndOwnerId(Constants.SiteConfigTypes.Logo, ownerId)
                                       .FirstOrDefault(x => x.Type == Constants.SiteConfigTypes.Logo);
                break;

            case "Footer":
                viewModel.FooterConfigs = _siteConfigService.GetConfigsByTypeAndOwnerId(Constants.SiteConfigTypes.Footer, ownerId);
                break;

            case "RightSide":
                viewModel.SocialConfigs = _siteConfigService.GetConfigsByTypeAndOwnerId(Constants.SiteConfigTypes.Social, ownerId);
                break;

            default:
                viewModel = CreateViewModel(ownerId);
                break;
            }

            return(viewModel);
        }
        public ActionResult CabinLayout(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Plane plane = _db.Planes.Find(id);

            if (plane == null)
            {
                return(HttpNotFound());
            }
            if (plane.Layout == null)
            {
                var layout = new LayoutViewModel()
                {
                    Height = 180,
                    Width  = 90,
                    Top    = 0,
                    Left   = 0
                };

                plane.Layout = layout;
                _db.SaveChanges();
            }
            return(View(plane.Layout));
        }
Exemple #10
0
        //// GET: ShowItem
        //public ActionResult Index()
        //{
        //    string idstr = Request.QueryString["id"];
        //    int id = 0;
        //    if (idstr == null || !Int32.TryParse(idstr, out id))
        //    {
        //        return View("error");
        //    }

        //    LayoutViewModel masterModel = new LayoutViewModel(db);
        //    ArticleContent model = db.ArticleContents.Find(id);
        //    // 根据不同的类型可以把title改下
        //    AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType);
        //    string emumtext = RemarkAttribute.GetEnumRemark(typeEnum);
        //    ViewBag.Title = "吉家尚" + emumtext + "详情页";
        //    ViewBag.Content = model.AContent;
        //    masterModel.groupBuilds = db.ArticleContents
        //                                .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper())
        //                                .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime })
        //                                .OrderBy(o => o.ACSortNum).ToList();

        //    return View(masterModel);
        //}

        /// <summary>
        /// 热门套餐,经典案例,团装,家居设计,环保装修详情页
        /// </summary>
        /// <returns></returns>
        public ActionResult ArticleContent()
        {
            string idstr = Request.QueryString["id"];
            int    id    = 0;

            if (idstr == null || !Int32.TryParse(idstr, out id))
            {
                return(View("error"));
            }

            ArticleContent model = db.ArticleContents.Find(id);

            if (model == null)
            {
                return(View("error"));
            }

            // 根据不同的类型可以把title改下
            AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType);
            string     emumtext = RemarkAttribute.GetEnumRemark(typeEnum);

            ViewBag.Title   = "吉家尚" + emumtext + "详情页";
            ViewBag.Content = model.AContent;

            LayoutViewModel masterModel = new LayoutViewModel(db);

            masterModel.groupBuilds = db.ArticleContents
                                      .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper())
                                      .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime })
                                      .OrderBy(o => o.ACSortNum).ToList();


            return(View(masterModel));
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            Repository <ApplicationUser> repoU    = new Repository <ApplicationUser>(new NeYapsakContext());
            Repository <Ilan>            repoIlan = new Repository <Ilan>(new NeYapsakContext());
            Repository <Katilan>         repoKat  = new Repository <Katilan>(new NeYapsakContext());
            Repository <Etiket>          repoE    = new Repository <Etiket>(new NeYapsakContext());
            Repository <IlanEtiket>      repoIE   = new Repository <IlanEtiket>(new NeYapsakContext());

            ViewBag.Etiketler     = repoE.GetAll().Where(e => e.Silindi == false).ToList();
            ViewBag.IlanEtiketler = repoIE.GetAll().Where(e => e.Silindi == false).ToList();

            LayoutViewModel LayoutModel = new LayoutViewModel();

            LayoutModel.Kullanici = repoU.GetAll().Where(u => u.Id == HttpContext.User.Identity.GetUserId()).FirstOrDefault();

            LayoutModel.KullaniciIlanSayisi = repoIlan.GetAll().Where(i => i.KullaniciId == HttpContext.User.Identity.GetUserId()).Count();

            LayoutModel.IlgilendigiIlanSayisi = repoKat.GetAll().Where(k => k.KullaniciId == HttpContext.User.Identity.GetUserId() && k.Onay == false && k.Silindi == false).Select(k => k.Ilan).Distinct().Count();

            LayoutModel.KatildigiIlanSayisi = repoKat.GetAll().Where(k => k.KullaniciId == HttpContext.User.Identity.GetUserId() && k.Onay == true && k.Silindi == false).Select(k => k.Ilan).Distinct().Count();

            LayoutModel.OnayimiBekleyenIlanSayisi = repoKat.GetAll().Where(k => k.Onay == false && k.Silindi == false).Select(k => k.Ilan).Distinct().Where(i => i.KullaniciId == HttpContext.User.Identity.GetUserId() && i.Silindi == false).Count();

            LayoutModel.OnayladigimIlanSayisi = repoKat.GetAll().Where(k => k.Onay == true && k.Silindi == false).Select(k => k.Ilan).Distinct().Where(i => i.KullaniciId == HttpContext.User.Identity.GetUserId() && i.Silindi == false).Count();

            ViewBag.user   = LayoutModel;
            ViewBag.UserID = HttpContext.User.Identity.GetUserId();
            base.OnActionExecuting(filterContext);
        }
Exemple #12
0
        public ActionResult Contact(ContactViewModel model)
        {
            Require.NotNull(model, "model");

            // Ontologie.
            Ontology.Title       = Strings.Home_Contact_Title;
            Ontology.Description = Strings.Home_Contact_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Contact();
            Ontology.SchemaOrg.ItemType         = SchemaOrgType.ContactPage;

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Contact());
            LayoutViewModel.MainHeading      = Strings.Home_Contact_MainHeading;
            LayoutViewModel.MainMenuCssClass = "contact";

            if (!ModelState.IsValid)
            {
                return(View(Constants.ViewName.Home.Contact, model));
            }

            _messenger.Publish(new NewContactMessage {
                EmailAddress   = new MailAddress(model.Email, model.Name),
                MessageContent = model.Message,
            });

            return(RedirectToRoute(Constants.RouteName.Home.ContactSuccess));
        }
        protected virtual ActionResult Message(string message)
        {
            var model = new LayoutViewModel <string>();

            model.Model = message;
            return(View("~/areas/public/views/shared/message.cshtml", model));
        }
 public HomeController()
 {
     #region Общий код для всех контроллеров
     SM.TryToLoginByCookiesIfNeed();
     ViewBag.L = LayoutViewModel.GetLayoutViewModel();
     #endregion
 }
        protected ActionResult Error(string message)
        {
            var model = new LayoutViewModel();

            model.Error = message;
            return(View("~/areas/public/views/shared/error.cshtml", model));
        }
Exemple #16
0
        private void InitMenuItems(ActionExecutingContext filterContext, ref LayoutViewModel model, ref BaseController controller)
        {
            var requestedUrl = filterContext.HttpContext.Request.RawUrl;

            model.MenuItems = new List <LayoutViewModel.MenuItem>
            {
                new LayoutViewModel.MenuItem
                {
                    Caption  = "Dashboard",
                    Icon     = "fa fa-dashboard",
                    Url      = controller.Url.RouteUrl(ControllerActionRouteNames.Home.DASHBOARD),
                    IsActive = requestedUrl == controller.Url.RouteUrl(ControllerActionRouteNames.Home.DASHBOARD)
                },

                new LayoutViewModel.MenuItem
                {
                    Caption  = "Users",
                    Icon     = "fa fa-users",
                    Url      = controller.Url.RouteUrl(ControllerActionRouteNames.Users.USERS),
                    IsActive = requestedUrl == controller.Url.RouteUrl(ControllerActionRouteNames.Users.USERS)
                }
            };

            model.TextAbort   = Resources.TextAbort;
            model.TextSuccess = Resources.TextSuccess;
        }
Exemple #17
0
    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        //Get the id from route
        var id = int.TryParse(ValueProvider.GetValue("id")?.AttemptedValue, out var temp)
                ? temp : default(int?);
        var model = new LayoutViewModel();

        //Your logic to initialize the model, for example
        model.Id = id;
        if (model.Id == null)
        {
            model.Color = "FF0000";
        }
        else if (model.Id % 2 == 0)
        {
            model.Color = "00FF00";
        }
        else
        {
            model.Color = "0000FF";
        }
        //Set ViewBag
        ViewBag.MainLayoutViewModel = model;
        base.OnActionExecuting(filterContext);
    }
Exemple #18
0
        public ActionResult Login(string returnUrl)
        {
            var model = new LayoutViewModel <string>();

            model.Model = returnUrl;
            return(AreaView("account/login.cshtml", model));
        }
Exemple #19
0
        public ActionResult Index()
        {
            // Modèle.
            var designers = _queries.ListDesigners(CultureInfo.CurrentUICulture);
            var patterns  = _queries.ListShowcasedPatterns();
            var model     = (from p in patterns
                             join d in designers on p.DesignerKey equals d.Key
                             select PatternViewItem.Of(p, d.DisplayName)).ToList();

            ShuffleList_(model);

            // Ontologie.
            Ontology.Title       = Strings.Home_Index_Title;
            Ontology.Description = Strings.Home_Index_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Home();

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Home());
            if (User.Identity.IsAuthenticated)
            {
                LayoutViewModel.MainHeading = Strings.Home_Index_MainHeading;
            }

            LayoutViewModel.MainMenuCssClass = "index";

            return(View(Constants.ViewName.Home.Index, model));
        }
Exemple #20
0
        public ActionResult Register(string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToHome());
            }

#if SHOWCASE
            return(Redirect("~/go?targetUrl=" + returnUrl));
#else
            // Modèle.
            var model = new RegisterViewModel {
                ReturnUrl = returnUrl,
            };

            // Ontologie.
            Ontology.Title       = Strings.Account_Register_Title;
            Ontology.Description = Strings.Account_Register_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Register();

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Register());
            LayoutViewModel.MainHeading      = Strings.Account_Register_MainHeading;
            LayoutViewModel.MainMenuCssClass = "register";

            return(View(Constants.ViewName.Account.Register, model));
#endif
        }
Exemple #21
0
        public ActionResult Contact()
        {
            // Modèle.
            var model = new ContactViewModel();

            if (User.Identity.IsAuthenticated)
            {
                model.Name = User.Identity.Name;

                // IMPORTANT: On doit vérifier si la session n'a pas disparue.
                // Cf. la remarque en début de la classe MemberSession.
                var session = MemberSession.Value;
                if (session != null)
                {
                    model.Email = session.Email;
                }
            }

            // Ontologie.
            Ontology.Title       = Strings.Home_Contact_Title;
            Ontology.Description = Strings.Home_Contact_Description;
            Ontology.Relationships.CanonicalUrl = SiteMap.Contact();
            Ontology.SchemaOrg.ItemType         = SchemaOrgType.ContactPage;

            // LayoutViewModel.
            LayoutViewModel.AddAlternateUrls(Environment.Language, _ => _.Contact());
            LayoutViewModel.MainHeading      = Strings.Home_Contact_MainHeading;
            LayoutViewModel.MainMenuCssClass = "contact";

            return(View(Constants.ViewName.Home.Contact, model));
        }
Exemple #22
0
        /// <summary>
        /// 设计师+案例
        /// </summary>
        /// <returns></returns>
        public ActionResult DesignerCase()
        {
            // 设计师编号
            string idstr = Request.QueryString["id"];
            int    id    = 0;

            if (idstr == null || !Int32.TryParse(idstr, out id))
            {
                return(View("error"));
            }

            LayoutViewModel layoutViewModel = new LayoutViewModel(db);

            layoutViewModel.designers = db.Designers.ToList();

            if (layoutViewModel.designers == null || layoutViewModel.designers.Count() == 0)
            {
                return(View("error"));
            }
            // 团装小区
            layoutViewModel.groupBuilds = db.ArticleContents
                                          .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper())
                                          .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime })
                                          .OrderBy(o => o.ACSortNum).ToList();

            ViewBag.Title = "吉家尚设计师" + layoutViewModel.designers.First().DName + "案例";
            layoutViewModel.classicCase = db.ArticleContents.Where(w => w.DId == id).ToList();
            ViewBag.CaseNameList        = string.Join("、", layoutViewModel.classicCase.Select(s => s.ACTitle));
            layoutViewModel.designers   = db.Designers.Where(w => w.Id == id).ToList();
            return(View(layoutViewModel));
        }
        public async Task <IActionResult> ForgotPassword(ForgotPasswordModel model)
        {
            ForgotPasswordModel obj         = new ForgotPasswordModel();
            LayoutViewModel     layoutModel = InitLayoutModel();

            obj.LayoutModel = layoutModel;
            if (!ModelState.IsValid)
            {
                return(View(obj));
            }
            var user = _context.Users.FirstOrDefault(t => t.Email == model.Email);

            if (user == null)
            {
                ModelState.AddModelError("", "Email is not valid");
                return(View(obj));
            }
            //var userName = user.UserProfile.FirstName +" "+ user.UserProfile.LastName;
            var          userName = user.Email;
            EmailService service  = new EmailService();

            string url = "https://localhost:44398/Account/ChangePassword/" + user.Id;
            await service.SendEmailAsync(model.Email, "ForgotPassword",
                                         $"Dear {userName}," +
                                         $"<br/>" +
                                         $"To change your change your password" +
                                         $"<br/>" +
                                         $"click on this link <a href='{url}'>press</a>");

            return(RedirectToAction("Index", "Home"));
        }
Exemple #24
0
        public IActionResult Catalog(int id, string name)
        {
            CatalogModel    obj         = new CatalogModel();
            LayoutViewModel layoutModel = InitLayoutModel();

            obj.LayoutModel = layoutModel;
            if (name == "Type")
            {
                obj.GetProducts = _products.GetProducts.Where(t => t.TypeId == id).ToList();
            }
            else if (name == "Material")
            {
                obj.GetProducts = _products.GetProducts.Where(t => t.MaterialId == id).ToList();
            }
            else if (name == "Model")
            {
                obj.GetProducts = _products.GetProducts.Where(t => t.ProductModelId == id).ToList();
            }
            else if (name == "Producer")
            {
                obj.GetProducts = _products.GetProducts.Where(t => t.ProducerId == id).ToList();
            }
            obj.ProductsCount      = _products.GetProducts.Count();
            obj.GetProductImages   = _productImages.GetProductImages.ToList();
            obj.ProductImagesCount = _productImages.GetProductImages.Count();
            return(View(obj));
        }
Exemple #25
0
        // GET: Index
        public ActionResult Index()
        {
            LayoutViewModel masterModel   = new LayoutViewModel(db);
            var             dbArticleSet  = db.ArticleContents;
            var             dbDesignerSet = db.Designers;

            masterModel.rollPictures = dbArticleSet.Where(w => w.ACType == AcTypeEmun.ROLL.ToString().ToUpper())
                                       .OrderBy(o => new { o.ACSortNum, o.InDateTime }).ToList();

            masterModel.hotPackages = dbArticleSet.Where(w => w.ACType == AcTypeEmun.HOTPACKAGE.ToString().ToUpper())
                                      .Take(3).OrderBy(o => new { o.ACSortNum, o.InDateTime }).ToList();

            masterModel.classicCase = dbArticleSet.Where(w => w.ACType == AcTypeEmun.CLASSCASE.ToString().ToUpper())
                                      .Take(5).OrderBy(o => new { o.ACSortNum, o.InDateTime }).ToList();

            masterModel.groupBuilds = dbArticleSet.Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper())
                                      .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }).OrderBy(o => o.ACSortNum).ToList();

            masterModel.homeDesigns = dbArticleSet.Where(w => w.ACType == AcTypeEmun.HOMEDESIGN.ToString().ToUpper())
                                      .Take(3).OrderBy(o => new { o.ACSortNum, o.InDateTime }).OrderBy(o => o.ACSortNum).ToList();

            masterModel.environmentalBuilds = dbArticleSet.Where(w => w.ACType == AcTypeEmun.ENVIRONMENTAL.ToString().ToUpper())
                                              .Take(3).OrderBy(o => new { o.ACSortNum, o.InDateTime }).ToList();

            masterModel.designers = dbDesignerSet.OrderBy(o => o.DSortNum).ToList();
            ViewBag.Title         = "吉家尚首页";

            return(View(masterModel));
        }
Exemple #26
0
        public ActionResult Search(string searchName)
        {
            string userId = Session["UserId"].ToString();

            SqlHelper.DbContext();
            Users user = SqlHelper.GetUser(userId);

            HttpCookie cookie = FormsAuthentication.GetAuthCookie(user.UserName, true);
            var        ticket = FormsAuthentication.Decrypt(cookie.Value);

            FormsAuthenticationTicket authTicket = new
                                                   FormsAuthenticationTicket(1,                           //version
                                                                             ticket.Name,
                                                                             DateTime.Now,                //creation
                                                                             DateTime.Now.AddMinutes(60), //Expiration
                                                                             true, "");
            // Encrypt the ticket.
            string encTicket = FormsAuthentication.Encrypt(authTicket);

            // Create the cookie.
            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

            LayoutViewModel layoutViewModel = new LayoutViewModel();

            return(View(layoutViewModel.LayoutViewModelUserSearchBuilder(Session["ProfileId"].ToString(), userId, searchName)));
        }
Exemple #27
0
        public async Task <IActionResult> Delete(int id)
        {
            if (HttpContext.Session.GetInt32("checkidAdmin") != null)
            {
                if (id == null)
                {
                    return(NotFound());
                }
                var category = await db.Categories
                               .Include(c => c.Parent)
                               .FirstOrDefaultAsync(m => m.Id == id);

                if (category == null)
                {
                    return(NotFound());
                }

                var viewlayout = new LayoutViewModel()
                {
                    CategoryVM = CategoryUtility.MapModeltoVM(category)
                };

                return(View(viewlayout));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Exemple #28
0
        public void SetLayout(LayoutViewModel layoutViewModel)
        {
            LayoutModel layout = pageContentService.Layout;

            layoutViewModel.LogoImage = new ResponsiveImageViewModel(
                layout.LogoImage.Title,
                TourtechUrlHelper.GetImageUrl(layout.LogoImage.ImageRelativeUrl),
                TourtechUrlHelper.GetImageUrl(layout.LogoImage.MobileImageRelativeUrl)
                );
            layoutViewModel.StripesImage   = ImageHelper.MapImageToViewModel(layout.StripesImage);
            layoutViewModel.HamburgerImage = ImageHelper.MapImageToViewModel(layout.HamburgerImage);

            IEnumerable <CategoryModel> categories = productsService.GetCategories();

            layoutViewModel.MainMenu =
                new MenuItemViewModel[]
            {
                new MenuItemViewModel("Home", Url.Action("Index", "Home")),
                new MenuItemViewModel(
                    "Products",
                    Url.Action("Index", "Products"),
                    categories.Select(a => new MenuItemViewModel(a.Title, TourtechUrlHelper.GetCategoryUrl(a.Name)))
                    ),
                new MenuItemViewModel("Where To Buy", Url.Action("Index", "WhereToBuy")),
            }
            ;
        }
Exemple #29
0
        public IActionResult SearchCategory(string keyword)
        {
            if (!string.IsNullOrEmpty(keyword))
            {
                var checkkeyword = db.Categories.Where(a => a.Name.Trim().Contains(keyword.Trim())).ToList();

                if (checkkeyword != null)
                {
                    var viewmodel = new LayoutViewModel()
                    {
                        CategoriesVM = CategoryUtility.MapModelsToVMs(checkkeyword.ToList())
                    };

                    return(View("Index", viewmodel));
                }
                else
                {
                    return(View("Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        internal static TemplateDelegate CompileView(ViewReaderFactory readerFactoryFactory, string templatePath, CompilationContext compilationContext)
        {
            var configuration = compilationContext.Configuration;
            IEnumerable <object> tokens;

            using (var sr = readerFactoryFactory(configuration, templatePath))
            {
                using (var reader = new ExtendedStringReader(sr))
                {
                    tokens = Tokenizer.Tokenize(reader).ToArray();
                }
            }

            var layoutToken = tokens.OfType <LayoutToken>().SingleOrDefault();

            var expressions  = ExpressionBuilder.ConvertTokensToExpressions(tokens, configuration);
            var compiledView = FunctionBuilder.Compile(expressions, compilationContext);

            if (layoutToken == null)
            {
                return(compiledView);
            }

            var fs         = configuration.FileSystem;
            var layoutPath = fs.Closest(templatePath, layoutToken.Value + ".hbs");

            if (layoutPath == null)
            {
                throw new InvalidOperationException($"Cannot find layout '{layoutToken.Value}' for template '{templatePath}'");
            }

            var compiledLayout = CompileView(readerFactoryFactory, layoutPath, new CompilationContext(compilationContext));

            return((in EncodedTextWriter writer, BindingContext context) =>
            {
                var config = context.Configuration;
                using var bindingContext = BindingContext.Create(config, null);
                foreach (var pair in context.ContextDataObject)
                {
                    switch (pair.Key.WellKnownVariable)
                    {
                    case WellKnownVariable.Parent:
                    case WellKnownVariable.Root:
                        continue;
                    }

                    bindingContext.ContextDataObject[pair.Key] = pair.Value;
                }

                using var innerWriter = ReusableStringWriter.Get(config.FormatProvider);
                using var textWriter = new EncodedTextWriter(innerWriter, config.TextEncoder, FormatterProvider.Current, true);
                compiledView(textWriter, context);
                var inner = innerWriter.ToString();

                var viewModel = new LayoutViewModel(inner, context.Value);
                bindingContext.Value = viewModel;

                compiledLayout(writer, bindingContext);
            });
 public MainWindow()
 {
     InitializeComponent();
     viewmodel  = new LayoutViewModel();
     this.DataContext = viewmodel;
 }