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); }
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"); }
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"); }
public void AddFont(FontRecord font) { _fontRepository.Create(font); }