private async Task <int> Update(int id, PageModuleModel pageModule) { var module = await _context.Modules.FindAsync(id); if (module == null) { return(default);
public async Task <int> AddOrUpdate(PageModuleModel pageModule) { if (Exists(pageModule.Id)) { return(await Update(pageModule.Id, pageModule)); } else { pageModule.SortId = GetNextId(); return(await Insert(pageModule)); } }
public static IEnumerable <(string Style, string Text)> ParseBadges(this PageModuleModel model) { if (string.IsNullOrWhiteSpace(model.Badges)) { yield return("danger", "Error-Parsing-Badge-Data"); } var splitBadges = model.Badges.Split(','); foreach (var badge in model.Badges.Split(',')) { var info = badge.Split(':'); yield return(info[0], info[1]); } }
public static bool HasContent(this PageModuleModel model) { if (string.IsNullOrWhiteSpace(model.Title) == false) { return(true); } if (string.IsNullOrWhiteSpace(model.Summary) == false) { return(true); } if (string.IsNullOrWhiteSpace(model.VideoSrc) == false) { return(true); } if (model.ImageCount > 0) { return(true); } return(false); }
public static bool HasCardContent(this PageModuleModel model) { if (string.IsNullOrWhiteSpace(model.Title) == false) { return(true); } if (string.IsNullOrWhiteSpace(model.Summary) == false) { return(true); } if (string.IsNullOrWhiteSpace(model.VideoSrc) == false) { return(true); } if (model.ImageCount > 0 && model.ImageType != (int)Enums.ImageTypes.Outside) { return(true); } return(false); }
private async Task <int> Insert(PageModuleModel pageModule) { _context.Modules.Add(pageModule); return(await _context.SaveChangesAsync()); }