Пример #1
0
 public void EditFont(FontRecord font)
 {
     FontRecord record = _fontRepository.Get(f => f.Id == font.Id);
     record.Family = font.Family;
     //record.FileName = font.FileName;
     record.Priority = font.Priority;
     record.Tags = font.Tags;
     _fontRepository.Update(record);
     
 }
Пример #2
0
 public RedirectToRouteResult AddNewFont(FontViewModel model)
 {
     string errorMsg = "";
     if (model.Family == null)
     {
         errorMsg += T("Font family is required.\n");
     }
     if (!((model.TtfFile == null) || (model.WoffFile == null)))
     {
         errorMsg += T("Font file is required.\n");
     }
     if (model.Thumbnail == null)
     {
         errorMsg += T("Thumbnail is required.\n");
     }
     if (errorMsg.Length > 0)
     {
         Services.Notifier.Error(T(errorMsg));
         return RedirectToAction("AddFont", model);
     }
     FontRecord newFont = new FontRecord() { };
     newFont.Family = model.Family;
     newFont.FileName = model.FileName;
     newFont.Priority = 0;
     newFont.FontCulture = cultureUsed;
     int i = 0;
     if (model.Tags != null)
     {
         string[] stringSeparators = new string[] { "," };
         string[] separatedTags;
         string resultTags = "[";
         separatedTags = model.Tags.Split(stringSeparators, StringSplitOptions.None);
         foreach (var item in separatedTags)
         {
             if (i != 0)
             {
                 resultTags = resultTags + ",";
             }
             resultTags = resultTags + "\"" + item  + "\"";
             i++;
         }
         resultTags += "]";
         newFont.Tags = resultTags;
     }
     _fontService.AddFont(newFont);
     Services.Notifier.Information(T("The font has been added"));
     return RedirectToAction("FontList");
 }
Пример #3
0
        public ActionResult UpdateFont(int id, string family, string tags)
        {

            FontRecord newFont = new FontRecord() { };
            newFont.Id = id;
            newFont.Family = family;
            newFont.Priority = 0;
            int i = 0;
            if (tags != null)
            {
                string[] stringSeparators = new string[] { "," };
                string[] separatedTags;
                string resultTags = "[";
                separatedTags = tags.Split(stringSeparators, StringSplitOptions.None);
                foreach (var item in separatedTags)
                {
                    if (i != 0)
                    {
                        resultTags = resultTags + ",";
                    }
                    resultTags = resultTags + "\"" + item + "\"";
                    i++;
                }
                resultTags += "]";
                newFont.Tags = resultTags;
            }
            _fontService.EditFont(newFont);
            Services.Notifier.Information(T("The font has been updated."));
            return RedirectToAction("FontList");
        }
Пример #4
0
        public void AddFont(FontRecord font)
        {
            _fontRepository.Create(font);

        }