public virtual void Localize(string name, string fromSite, Site targetSite) { var sourceSite = ServiceFactory.SiteManager.GetSite(SiteHelper.SplitFullName(fromSite)); var source = new Models.Theme(sourceSite, name); ILocalizableHelper.Localize <Models.Theme>(source, targetSite); }
public async Task <IActionResult> PostContextAsync([FromBody] Models.Theme theme) { try { if (await context.Theme.AnyAsync(o => o.Index.Equals(theme.Index))) { if (context.Theme.Any(o => o.Date.Equals(theme.Date) && o.Index.Equals(theme.Index))) { return(Ok()); } context.Entry(theme).State = EntityState.Modified; } else { context.Theme.Add(theme); } return(Ok(context.SaveChanges())); } catch (Exception ex) { Console.WriteLine($"{GetType()}\n{ex.Message}\n{nameof(this.PostContextAsync)}"); } return(BadRequest()); }
public ActionResult Create(Models.Theme createCate) { if (Session["accname"] == null) { Session["accname"] = null; return(RedirectToAction("Login", "Account")); } else { try { EX ex = new EX(); var a = ex.theme(createCate.TenChuDe); int b = a.Count(); if (b == 0) { dbCate.Themes.Add(createCate); dbCate.SaveChanges(); SetAlert("Thêm mới chủ đề thành công!", "success"); return(RedirectToAction("Index", "Theme")); } else { ViewBag.Createtheme = "Tên danh mục đã tồn tại."; } } catch (Exception) { ViewBag.CreateCategory = "Không thể thêm danh mục."; } return(View()); } }
public ActionResult Edit(Models.Theme editCate) { if (Session["accname"] == null) { Session["accname"] = null; return(RedirectToAction("Login", "Account")); } else { try { EX ex = new EX(); var a = ex.prtname(editCate.TenChuDe); int b = a.Count(); if (b == 0) { dbCate.Entry(editCate).State = System.Data.Entity.EntityState.Modified; dbCate.SaveChanges(); SetAlert("Cập nhật chủ đề thành công!", "success"); return(RedirectToAction("Index", "Theme")); } else { ViewBag.CreateCategory = "Tên danh mục đã tồn tại."; } } catch (Exception) { ViewBag.EditCategory = "Không thể cập nhật danh mục."; } return(View()); } }
public override Models.ILiiteriMarker Create(DbDataReader rdr) { var obj = new Models.Theme(); obj.Id = (int)rdr["Id"]; obj.Name = rdr["Name"].ToString(); obj.ParentId = (int?)this.GetValueOrNull(rdr, "ParentId"); return(obj); }
public string AddTheme(Models.Theme theme) { if (Session["userId"] == null) { return("<b>Please log in</b>"); } theme.IdAutor = (int)Session["userId"]; theme.DTCreated = DateTime.Now; forum.Theme.Add(theme); forum.SaveChanges(); return("<b>Theme added</b> \n <b><a href='/Home'>Back</a></b> "); }
public static void InstallTheme(Models.Theme theme) { var filePath = Portal.ResolvePath(ThemePath); var fileName = filePath + theme.Name + ".manifest"; if (!System.IO.File.Exists(filePath + theme.Name + ".manifest")) { theme.Thumbnail = DownloadResource(theme.Thumbnail, ThemePath.PathCombine(theme.Name)); foreach (var file in theme.Files) { file.Path = DownloadResource(file.Path, ThemePath.PathCombine(theme.Name)); } theme.ToJson().WriteText(fileName); } else { throw new Exception(string.Format(Localization.GetLocalization(LocalizationType.Exception, "DuplicateResource.Error", "{0} already exists. Duplicates Not Allowed.", "Core"), "Theme")); } }