public IActionResult Create(ModelViewAdmin model) { if (ModelState.IsValid) { _admin.Add(model); return(RedirectToAction("Index")); } return(View()); }
public static int Add(AdminInfo entity) { entity.Id = dal.Add(entity); AdminGroupBLL.ChangeCount(entity.GroupId, ChangeAction.Plus); return(entity.Id); }
public ActionResult Register(Register par) { if (!ModelState.IsValid) { ViewBag.msgError = fn.fg.DataIsntValid; ViewBag.GENDER_ID = ddlGender(); ViewBag.IdGroup = ddlGroup(); } else { if (par.ID_GROUP == 0) { par.ID_GROUP = 4; } if (Session["UserId"] != null) { if (Session["IdGroup"].ToString() == "1" || bool.Parse(Session["IsSuperAdmin"].ToString()) == true) { par.IsSuperAdmin = true; } else { par.IsSuperAdmin = false; } par.CREATED_BY = Session["UserName"].ToString(); } else { par.CREATED_BY = par.Name; } var isSave = repo.Add(par); if ((bool)isSave[0] == true) { ViewBag.msgSuccess = fn.fg.Save; ViewBag.GENDER_ID = ddlGender(); ViewBag.IdGroup = ddlGroup(); } else { switch ((string)isSave[1]) { case "password": ViewBag.msgError = "Password does'nt match!"; break; case "email": ViewBag.msgError = "Email does'nt valid!"; break; default: ViewBag.msgError = fn.fg.SFailed; break; } ViewBag.GENDER_ID = ddlGender(); ViewBag.IdGroup = ddlGroup(); } } return(View()); }
public IActionResult DownNews() { //var newFeed = new Feed { }; var sessionId = Guid.NewGuid().ToString(); int totalRecords = 0; decimal numPages = 0; int numPagesInt = 0; int pageSize = 100; var runDate = DateTime.Now; var lastPubDate = DateTime.Now; var q = "trump"; var sources = string.Empty; var domains = string.Empty; var excludeDomains = string.Empty; var from = DateTime.Now.AddDays(-3); var to = DateTime.Now; var language = "en"; var sortBy = "PublishedAt"; var page = 1; // init with your API key var newsApiClient = new NewsApiClient("de67b2237afe4fb1b77bfbe773987fca"); var articlesResponse = newsApiClient.GetEverything(new EverythingRequest { Q = q, SortBy = SortBys.PublishedAt, Language = Languages.EN, From = from, PageSize = pageSize, Page = page }); if (articlesResponse.Status == Statuses.Ok) { totalRecords = articlesResponse.TotalResults; numPages = totalRecords / pageSize; numPagesInt = Convert.ToInt32(Math.Ceiling(numPages)); foreach (var article in articlesResponse.Articles) { var newFeed = new Feed(); newFeed.SessionId = sessionId; newFeed.TotalResults = articlesResponse.TotalResults; newFeed.SourceId = 0; //what format? newFeed.SourceName = article.Source.Name; newFeed.Author = article.Author; newFeed.Description = article.Description; newFeed.PublishedAt = Convert.ToDateTime(article.PublishedAt); newFeed.Title = article.Title; newFeed.Url = article.Url; newFeed.UrlToImage = article.UrlToImage; newFeed.Content = string.Empty; //feedList.Content = article.Content; //not available in .net. Available in JS. //add to table _feed.Add(newFeed); } } var newAdmin = new Admin { SessionId = sessionId, RunDate = runDate, LastPubDate = _admin.GetLastPubDate(), Q = q, Sources = sources, Domains = domains, ExcludeDomains = excludeDomains, From = from, To = to, Language = language, SortBy = sortBy, PageSize = pageSize, Page = page }; //todo: add to Admin _admin.Add(newAdmin); return(RedirectToAction("Index")); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.Admin model) { return(dal.Add(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Hch.iDisk.Model.Admin model) { dal.Add(model); }