예제 #1
0
 public ActionResult EditFont(int id)
 {
     FontRecord record = _fontService.GetFont(id);
     FontViewModel editRecord = new FontViewModel() { };
     editRecord.Id = record.Id;
     editRecord.Family = record.Family;
     editRecord.FileName = record.FileName;
     string[] stringSeparators = new string[] { ","};
     string[] separatedTags;
     string Tags = record.Tags.Trim(new Char[] { '[', '*', ',', ']',' ', '.' });          
     Tags = Tags.Replace("\"","");
     string resultTags = "";
     separatedTags = Tags.Split(stringSeparators, StringSplitOptions.None);
     int i = 0;
     foreach (var item in separatedTags)
     {
         if (i != 0)
         {
             resultTags = resultTags + "," + " ";
         }
         resultTags = resultTags + item;
         i++;
     }
     editRecord.Tags = resultTags;
     return View(editRecord);
 }
예제 #2
0
 public ActionResult AddFont(FontViewModel record)
 {
     if (record != null)
     {
         return View(record);
     }
     return View();
 }
예제 #3
0
 public RedirectToRouteResult UploadWoffFile(HttpPostedFileBase file, FontViewModel model)
 {
     if (file != null && file.ContentLength > 0)
     {
         string[] allowed = { ".woff" };
         var extension = System.IO.Path.GetExtension(file.FileName);
         if (allowed.Contains(extension))
         {
             string fileExt = Path.GetExtension(file.FileName);
             string fileName = Path.GetFileNameWithoutExtension(file.FileName).Replace("-webfont", "");
             var path = Path.Combine(Server.MapPath("/Modules/Teeyoot.Module/Content/fonts/"), file.FileName);
             file.SaveAs(path);
             model.WoffFile = file.FileName;
             model.FileName = fileName;
             Services.Notifier.Information(T("WOFF file has been added!"));
             return RedirectToAction("AddFont", model);
         }
     }
     Services.Notifier.Error(T("Wrong file extention!"));
     return RedirectToAction("AddFont", model);
 }
예제 #4
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");
 }