public ActionResult ApplyBlogTemplate(StyleModel model)
        {
            var currentBlog = _blogRepo.GetCurrentBlog(_httpContext);

            if (ModelState.IsValid)
            {
                var blogTemplate = _styleRepo.GetLatestEditForBlog(currentBlog.Id);
                if (currentBlog.BlogTemplateId == blogTemplate.Id)
                {
                    //no need to apply we already are
                    return(Json(new { success = true }));
                }

                blogTemplate.Css          = model.Css;
                blogTemplate.HtmlTemplate = model.HtmlTemplate;
                blogTemplate.TemplateMode = model.TemplateMode;
                blogTemplate.LastModified = DateTime.Now;
                _styleRepo.Update(blogTemplate);

                currentBlog.BlogTemplateId = blogTemplate.Id;
                _blogRepo.Update(currentBlog);

                return(Json(new { success = true }));
            }

            return(Json(new { success = false }));
        }
Пример #2
0
        /// <summary>
        /// Fills a <see cref="OfficeOpenXml.Style.ExcelStyle" /> object with model data.
        /// </summary>
        /// <param name="style"><see cref="OfficeOpenXml.Style.ExcelStyle" /> object.</param>
        /// <param name="model">Style model definition.</param>
        /// <param name="useAlternate"><b>true</b> for use alternate color; Otherwise <b></b>.</param>
        /// <exception cref="System.ArgumentNullException">If <paramref name="style" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">If <paramref name="model" /> is <c>null</c>.</exception>
        public static void FormatFromModel(this ExcelStyle style, StyleModel model, bool useAlternate = false)
        {
            SentinelHelper.ArgumentNull(style);
            SentinelHelper.ArgumentNull(model);

            var hasInheritStyle = !string.IsNullOrEmpty(model.Inherits);

            if (hasInheritStyle)
            {
                var inheritStyle = model.TryGetInheritStyle();
                model.Combine(inheritStyle);
            }

            style.Font.SetFromFont(model.Font.ToFont());
            style.Font.Color.SetColor(model.Font.GetColor());

            var content = model.Content;

            style.VerticalAlignment   = content.Alignment.Vertical.ToEppVerticalAlignment();
            style.HorizontalAlignment = content.Alignment.Horizontal.ToEppHorizontalAlignment();

            style.Fill.PatternType = content.Pattern.PatternType.ToEppPatternFillStyle();
            if (style.Fill.PatternType != ExcelFillStyle.None)
            {
                style.Fill.BackgroundColor.SetColor(useAlternate ? content.GetAlternateColor() : content.GetColor());
                style.Fill.PatternColor.SetColor(content.Pattern.GetColor());
            }

            style.Numberformat.Format = content.DataType.GetDataFormat().ToEppDataFormat(content.DataType);

            foreach (var border in model.Borders)
            {
                style.Border.CreateFromModel(border);
            }
        }
Пример #3
0
        public IActionResult PostStyle([FromBody] StyleModel styleModel)
        {
            _logger.LogInformation($"{nameof(StyleController)} : {nameof(PostStyle)} was called.");
            try
            {
                if (styleModel == null)
                {
                    return(BadRequest("Style is required"));
                }

                if (_styleService.FindById(styleModel.Id) != null)
                {
                    return(Conflict("Style already exists"));
                }

                _styleService.Create(styleModel);
                _styleService.Save();
                return(Ok("Style Created"));
            }
            catch (DbException exception)
            {
                _logger.LogError(exception.Message);
                return(BadRequest(exception.Message));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw;
            }
        }
Пример #4
0
 public IActionResult UpdateStyle([FromBody] StyleModel styleModel)
 {
     _logger.LogInformation($"{nameof(StyleController)} : {nameof(UpdateStyle)} was called.");
     try
     {
         if (styleModel == null)
         {
             return(BadRequest("Style is required"));
         }
         if (_styleService.FindById(styleModel.Id) == null)
         {
             return(NotFound("Style not found"));
         }
         _styleService.Update(styleModel);
         _styleService.Save();
         return(Ok());
     }
     catch (DbException exception)
     {
         _logger.LogError(exception.Message);
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         _logger.LogError(exception.Message);
         throw;
     }
 }
Пример #5
0
        public List <StyleModel> GetStyles()
        {
            if (_albumJSON == null)
            {
                return(null);
            }

            try
            {
                List <StyleModel> styles = new List <StyleModel>();

                foreach (var s in _albumJSON["styles"])
                {
                    StyleModel style = new StyleModel()
                    {
                        Style = s.ToString()
                    };
                    styles.Add(style);
                }

                return(styles);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #6
0
        public static void EditScriptFile(CMSDatabase db, string path, StyleModel model, HttpContext context, out string redirectPath, out bool successfullyCompleted)
        {
            Regex regex = new Regex(@"^((\w|-|_)+)(>(\w|-|_)+)*\.js$");

            if (!regex.IsMatch(path))
            {
                successfullyCompleted = false;
                redirectPath          = string.Empty;
                return;
            }
            IHostingEnvironment env   = context.RequestServices.GetService <IHostingEnvironment>();
            string scriptFileFullName = path.Substring(path.LastIndexOf('>') + 1);

            path = path.Substring(0, path.Length - scriptFileFullName.Length);
            if (!string.IsNullOrEmpty(path))
            {
                path = path.Replace('>', '/');
                if (!path[path.Length - 1].Equals('/'))
                {
                    path = path.Insert(path.Length, "/");
                }
            }
            path = $"{env.GetStorageFolderFullPath()}{path}";
            string pathToFile = path + scriptFileFullName;

            if (!File.Exists(pathToFile) || !HasAccessToFolder(path, env))
            {
                successfullyCompleted = false;
                redirectPath          = string.Empty;
                return;
            }
            model.FileName = OtherFunctions.GetCorrectName(model.FileName, context);
            if (string.IsNullOrEmpty(model.FileName))
            {
                successfullyCompleted = false;
                redirectPath          = string.Empty;
                return;
            }
            string oldScriptFileName  = scriptFileFullName.Substring(0, scriptFileFullName.Length - 3);
            string scriptFileFullPath = $"{path}{model.FileName}.js";

            if (!oldScriptFileName.Equals(model.FileName, StringComparison.Ordinal))
            {
                File.Move($"{pathToFile}", scriptFileFullPath);
            }
            using (StreamWriter writer = new StreamWriter(scriptFileFullPath))
            {
                writer.Write(model.FileContent);
            }
            successfullyCompleted = true;
            redirectPath          = scriptFileFullPath.Substring(env.GetStorageFolderFullPath().Length).Replace('/', '>');

            LogManagementFunctions.AddAdminPanelLog(
                db: db,
                context: context,
                info: $"{pathToFile.Substring(env.GetStorageFolderFullPath().Length - 1)}{(!oldScriptFileName.Equals(model.FileName, StringComparison.Ordinal) ? $" -> {scriptFileFullPath.Substring(env.GetStorageFolderFullPath().Length - 1)}" : string.Empty)}: " +
                $"{(context.Items["LogLocalization"] as IAdminPanelLogLocalization)?.FileEdited}"
                );
        }
Пример #7
0
        public Style Bind(StyleModel styleModel)
        {
            Style style = new Style();

            style.Id   = styleModel.Id;
            style.Name = styleModel.Name;

            return(style);
        }
 public void TestInitialize()
 {
     style      = Utils.CreateStyleForTest();
     styleModel = StyleModel.ToModel(style);
     mockUserAuthorizationLogic = new Mock <IAuthorizationBusinessLogic>();
     mockStyleBusinessLogic     = new Mock <IStyleBusinessLogic>();
     styleController            = new StyleController(mockStyleBusinessLogic.Object, mockUserAuthorizationLogic.Object);
     InitializeToken();
 }
Пример #9
0
        public void Update(StyleModel entity)
        {
            var index = _styleModels.FindIndex(a => a.Id == entity.Id);

            if (index > 0)
            {
                _styleModels[index] = entity;
            }
        }
        public IActionResult AddArtwork(ArtworkViewModel model)
        {
            ArtistModel artistmodel = _artistDataManager.GetOneArtist(model.SelectedArtist);
            StyleModel  stylemodel  = _artworkDataManager.GetOneStyle(model.SelectedStyle);

            _artworkDataManager.AddArtwork(model.Title, artistmodel, stylemodel, model.Year, model.Description, model.Type, model.Price, model.Availability);

            return(RedirectToAction(nameof(Index)));
        }
Пример #11
0
        /// <summary>
        /// Creates a new cell with the visual style defined in the model.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="style">The style.</param>
        /// <returns>
        /// A new <see cref="T:iTextSharp.text.pdf.PdfPCell" /> with visual style defined in the model.
        /// </returns>
        public static PdfPCell CreateCell(string text, StyleModel style)
        {
            var phrase = new Phrase {
                Font = CreateFont(style.Font)
            };

            phrase.Add(text);

            return(new PdfPCell(phrase).SetVisualStyle(style));
        }
Пример #12
0
        internal static IList <StyleModel> ConvertEntitiesToModels(IList <Style> styles)
        {
            IList <StyleModel> stylesModels = new List <StyleModel>();

            foreach (Style style in styles)
            {
                stylesModels.Add(StyleModel.ToModel(style));
            }
            return(stylesModels);
        }
        internal void AddStyle(string style)
        {
            var item = new StyleModel()
            {
                Style = style
            };

            _dbContext.Styles.Add(item);
            _dbContext.SaveChanges();
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] StyleModel styleModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(styleModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(styleModel));
 }
Пример #15
0
        /// <summary>
        /// Appends the visual style to this paragraph.
        /// </summary>
        /// <param name="cell">The cell.</param>
        /// <param name="style">The style.</param>
        /// <returns>
        /// A <see cref="T:Novacode.Paragraph" /> with the style.
        /// </returns>
        public static Paragraph AppendVisualStyle(this Cell cell, StyleModel style)
        {
            SentinelHelper.ArgumentNull(cell);
            SentinelHelper.ArgumentNull(style);

            var paragraph = cell.AppendCommonVisualStyle(style);

            paragraph.Color(style.Font.GetColor());

            return(paragraph);
        }
Пример #16
0
        /// <summary>
        /// Sets visual style for specified cell.
        /// </summary>
        /// <param name="cell">Cell which receives visual style.</param>
        /// <param name="style">Style to apply.</param>
        /// <returns>
        /// A <see cref="T:iTextSharp.text.pdf.PdfPCell" /> object which contains specified visual style.
        /// </returns>
        public static PdfPCell SetVisualStyle(this PdfPCell cell, StyleModel style)
        {
            SentinelHelper.ArgumentNull(cell);
            SentinelHelper.ArgumentNull(style);

            cell.BackgroundColor     = new BaseColor(style.Content.GetColor());
            cell.VerticalAlignment   = style.Content.Alignment.Vertical.ToElementVerticalAlignment();
            cell.HorizontalAlignment = style.Content.Alignment.Horizontal.ToElementHorizontalAlignment();

            return(cell);
        }
Пример #17
0
        public ActionResult Index()
        {
            StyleModel styleModel = new StyleModel();
            styleModel.EventCommand = "page";
            
            HandleRequest(styleModel);
            styleModel.Styles = Styles;

            ModelState.Clear();

            return View(styleModel);
        }
Пример #18
0
 public static StyleEntity ToEntity(StyleModel styleModel)
 {
     if (styleModel == null)
     {
         return(null);
     }
     return(new StyleEntity
     {
         Description = styleModel.Description,
         Id = styleModel.Id,
         Name = styleModel.Name
     });
 }
        public void UpdateStyle_WhenCalledIncorrectly_ReturnsNotFoundResult()
        {
            // Arrange
            var style = new StyleModel {
                Id = -1
            };

            // Act
            var result = _controller.UpdateStyle(style);

            // Assert
            Assert.IsType <NotFoundObjectResult>(result);
        }
        public void PostStyle_WhenCalled_ReturnsOkResult()
        {
            // Arrange
            var style = new StyleModel {
                Id = 4
            };

            // Act
            var result = _controller.PostStyle(style);

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }
        public void DeleteAlbumStyles(List <StyleModel> styles)
        {
            StyleModel beforeStyle = new StyleModel();

            foreach (var style in styles)
            {
                if (style != beforeStyle)
                {
                    _context.Styles.Remove(style);
                }
                beforeStyle = style;
            }
        }
        public ActionResult Create([Bind(Include = "Id,Name")] StyleModel styleModel)
        {
            if (ModelState.IsValid)
            {
                StyleBinder styleBinder = new StyleBinder();
                Style       style       = styleBinder.Bind(styleModel);
                db.Style.Add(style);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(styleModel));
        }
Пример #23
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            //element.BindingGroup = default;
            //element.ContextMenu = default;
            //element.Cursor = default;
            //element.DataContext =
            bool isParsed = Enum.TryParse(FlowDirection, out FlowDirection flowDirection);

            element.FlowDirection = isParsed ? flowDirection : default;

            //Bind focus visual style
            element.FocusVisualStyle = StyleModel.TryGetStyle <Style>(styleModels, FocusVisualStyleId);

            element.ForceCursor         = ForceCursor;
            element.Height              = Height;
            isParsed                    = Enum.TryParse(HorizontalAlignment, out HorizontalAlignment horizontalAlignment);
            element.HorizontalAlignment = isParsed ? horizontalAlignment : default;
            //element.InputScope
            if (!string.IsNullOrWhiteSpace(Language))
            {
                element.Language = XmlLanguage.GetLanguage(Language);
            }
            if (!string.IsNullOrWhiteSpace(LayoutTransform))
            {
                element.LayoutTransform = Transform.Parse(LayoutTransform);
            }
            element.Margin                = new Thickness(Margin);
            element.MaxHeight             = MaxHeight;
            element.MaxWidth              = MaxWidth;
            element.MinHeight             = MinHeight;
            element.MinWidth              = MinWidth;
            element.Name                  = Name;
            element.OverridesDefaultStyle = OverridesDefaultStyle;
            //element.Resources;

            //Bind style
            element.Style = StyleModel.TryGetStyle <Style>(styleModels, StyleId);

            //element.Tag;
            //element.ToolTip;
            element.UseLayoutRounding = UseLayoutRounding;
            isParsed = Enum.TryParse(VerticalAlignment, out VerticalAlignment verticalAlignment);
            element.VerticalAlignment = isParsed ? verticalAlignment : default;
            element.Width             = Width;
        }
Пример #24
0
        public ICollection <StyleModel> Bind(ICollection <Style> style)
        {
            ICollection <StyleModel> styleModelList = new List <StyleModel>();

            foreach (Style item in style)
            {
                StyleModel styleModel = new StyleModel();
                styleModel.Id   = item.Id;
                styleModel.Name = item.Name;
                styleModelList.Add(styleModel);
            }

            return(styleModelList);
        }
 public IHttpActionResult AddStyleToStyleClass([FromUri] Guid styleClassId, [FromBody] StyleModel styleModel)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         StyleClassBusinessLogic.AddStyle(styleClassId, styleModel.ToEntity());
         return(Ok("Style added to Style Class"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public ActionResult Edit(Guid id, StyleModel model)
        {
            if (ModelState.IsValid)
            {
                var style = _styleRepo.GetBy(s => s.Id == id);

                style.Css = model.Css;
                _styleRepo.Update(style);

                return(Json(new { success = true }));
            }

            return(PartialView("EditStyleModal", model));
        }
Пример #27
0
        public ActionResult Create(StyleModel model)
        {
            ResponseJson response = new ResponseJson();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(Globals.SetValidationError(ModelState)));
                }
                //response = Validation(response, model);
                //if (response.IsError)
                //{
                //    return Json(response);
                //}
                //ObjectParameter ErrorCode = new ObjectParameter("ErrorCode", 0);
                UpdatedInfoModel updatedInfo = new UpdatedInfoModel()
                {
                    Comment = "Style Created", Type = 1, UpdatedTime = DateTime.Now, UserId = CurrentUser.Id
                };
                using (AppDB db = new AppDB())
                {
                    DAL.Style style = new DAL.Style()
                    {
                        Id           = Guid.NewGuid(),
                        BuyerId      = model.BuyerId,
                        BarCode      = Globals.GetBarCode(),
                        Name         = model.Name,
                        CreatedBy    = CurrentUser.Id,
                        YarnType     = model.YarnType,
                        Size         = model.Size,
                        Description  = model.Description,
                        ShippingDate = model.ShippingDate,
                        Status       = 0,
                        CreatedAt    = DateTime.Now,
                        Quantity     = model.Quantity,
                        UpdateInfo   = new JavaScriptSerializer().Serialize(updatedInfo)
                    };
                    db.Styles.Add(style);
                    db.SaveChanges();
                    //EmailSender.SendToCHWUser(model.Email, login, login, model.Surname, "Sector Executive Officer");
                }
            }
            catch (Exception ex)
            {
                response.IsError = true;
                response.Id      = -6;
            }
            return(Json(response));
        }
        public List <StyleModel> GetTrimedStyles(string styles)
        {
            string[] styTab  = styles.Split(",");
            var      styList = new List <StyleModel>();

            for (int i = 0; i < styTab.Length; i++)
            {
                var st = new StyleModel();
                st.Style = styTab[i].Trim();
                styList.Add(st);
            }

            return(styList);
        }
Пример #29
0
        // GET: Collections
        public ActionResult Index(int?CompanyId)
        {
            if (CompanyId == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Company           co          = db.FindCompany(CompanyId);
            List <Collection> collections = db.Collections.Include("Styles").Include("Styles.Memos").Where(c => c.CompanyId == co.Id).ToList();

            if (co == null)
            {
                return(HttpNotFound());
            }

            CollectionViewModel m = new CollectionViewModel();

            m.CompanyId   = co.Id;
            m.CompanyName = co.Name;
            m.Collections = new List <CollectionModel>();
            foreach (Collection coll in collections.OrderBy(c => c.Name))
            {
                CollectionModel collM = new CollectionModel()
                {
                    Id        = coll.Id,
                    CompanyId = coll.CompanyId,
                    Name      = coll.Name
                };
                collM.Styles = new List <StyleModel>();
                foreach (Style sty in coll.Styles.OrderBy(s => s.StyleName).ThenBy(s => s.Desc))
                {
                    StyleModel styM = new StyleModel()
                    {
                        Id    = sty.Id,
                        Image = sty.Image,
                        Desc  = sty.Desc,
                        Name  = sty.StyleName,
                        //Num = sty.StyleNum,
                        Memod       = sty.Memos.Sum(s => s.Quantity),
                        Qty         = sty.Quantity,
                        RetialPrice = sty.RetailPrice ?? 0,
                        // Cost is the sum of the component prices
                        //Retail Price is the cost * retail ratio
                    };
                    collM.Styles.Add(styM);
                }
                m.Collections.Add(collM);
            }
            return(View(m));
        }
Пример #30
0
 public IHttpActionResult Post([FromBody] StyleModel styleModel)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         StyleBusinessLogic.Add(styleModel.ToEntity());
         return(Ok(styleModel));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #31
0
 public IHttpActionResult Get([FromUri] string name)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic);
         Style style = StyleBusinessLogic.Get(name);
         return(Ok(StyleModel.ToModel(style)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #32
0
        private void Init(StyleModel vm)
        {
            vm.EventCommand = string.Empty;
            vm.EventArgument = string.Empty;

            vm.Pager = new Pager();
            vm.IsPagerVisible = true;

            // initial sort expression
            vm.EventCommand = "sort";
            vm.SortExpression = "MerretDescription";
            vm.SortDirection = SortDirection.Ascending;
            vm.LastSortExpression = string.Empty;
            vm.SortDirectionNew = SortDirection.Ascending;
        }
Пример #33
0
        public ActionResult Index(StyleModel styleModel)
        {
            try
            {

                System.Threading.Thread.Sleep(2000);

                HandleRequest(styleModel);

                styleModel.Styles = Styles;
                // NOTE: Must clear the model state in order to bind
                //       the @Html helpers to the new model values
                ModelState.Clear();

                return View(styleModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #34
0
 public void LoadStyles(StyleModel styleModel)
 {
     Styles = _StyleService.GetPagedStyles(
                                 styleModel.Pager.PageIndex,
                                 styleModel.Pager.PageSize,
                                 new string[] { }).ToList();
 }
Пример #35
0
        public void HandleRequest(StyleModel styleModel)
        {

            //styleModel.HandleRequest();

            if (styleModel.EventCommand == "sort")
            {
                // Check to see if we need to change the sort order 
                // because the sort expression changed
                styleModel.SetSortDirection();
            }

            switch (styleModel.EventCommand)
            {
                case "page":
                case "sort":
                case "search":
                    
                    styleModel.QuantityOfRecords = _StyleService.GetTotalOfStyles();
                    // Setup Pager Object
                    styleModel.SetPagerObject(styleModel.QuantityOfRecords);

                    styleModel.QuantityOfPages = styleModel.Pages.Count();

                    // Get Products for the current page
                    LoadStyles(styleModel);

                    break;
            }
        }