public static NotifyNew Update(NotifyNew data) { using (var con = new inventorymanagementEntities()) { var post = con.NotifyNews.Where(o => o.ID == data.ID).FirstOrDefault(); if (post != null) { post.Action = data.Action; post.ActionValue = data.ActionValue; post.AtHome = data.AtHome; post.CategoryID = data.CategoryID; post.CategorySlug = data.CategorySlug; post.Content = data.Content; post.CreatedBy = data.CreatedBy; post.CreatedDate = data.CreatedDate; post.ModifiedBy = data.ModifiedBy; post.ModifiedDate = data.ModifiedDate; post.Summary = data.Summary; post.Thumbnail = data.Thumbnail; post.Title = data.Title; con.SaveChanges(); return(post); } return(null); } }
public static NotifyNew Insert(NotifyNew data) { using (var con = new inventorymanagementEntities()) { con.NotifyNews.Add(data); con.SaveChanges(); return(data); } }
public static NotifyNew GetByID(int ID) { using (var dbe = new inventorymanagementEntities()) { NotifyNew ai = dbe.NotifyNews.Where(a => a.ID == ID).SingleOrDefault(); if (ai != null) { return(ai); } else { return(null); } } }
public static string Delete(int ID) { using (var dbe = new inventorymanagementEntities()) { NotifyNew ui = dbe.NotifyNews.Where(o => o.ID == ID).FirstOrDefault(); if (ui != null) { dbe.NotifyNews.Remove(ui); int kq = dbe.SaveChanges(); return(kq.ToString()); } else { return(null); } } }
public static string UpdateImage(int ID, string Thumbnail) { using (var dbe = new inventorymanagementEntities()) { NotifyNew ui = dbe.NotifyNews.Where(a => a.ID == ID).SingleOrDefault(); if (ui != null) { ui.Thumbnail = Thumbnail; int kq = dbe.SaveChanges(); return(kq.ToString()); } else { return(null); } } }
public static string upTopAppUpdate(int id) { using (var dbe = new inventorymanagementEntities()) { NotifyNew ui = dbe.NotifyNews.Where(a => a.ID == id).SingleOrDefault(); if (ui != null) { ui.AppUpdate = DateTime.Now; int kq = dbe.SaveChanges(); return(kq.ToString()); } else { return(null); } } }
public static string updateAtHome(int id, bool value) { using (var dbe = new inventorymanagementEntities()) { NotifyNew ui = dbe.NotifyNews.Where(a => a.ID == id).SingleOrDefault(); if (ui != null) { ui.AtHome = value; int kq = dbe.SaveChanges(); return(kq.ToString()); } else { return(null); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { int CategoryID = ddlCategory.Value.ToInt(); var category = NotifyCategoryController.GetByID(CategoryID); string CategorySlug = category.Slug; string Title = txtTitle.Text.Trim(); string Slugs = Slug.ConvertToSlug(txtSlug.Text.Trim()); string Link = txtLink.Text.Trim(); string Content = pContent.Content.ToString(); string Summary = HttpUtility.HtmlDecode(pSummary.Content.ToString()); string Action = ddlAction.SelectedValue.ToString(); string ActionValue = ""; if (Action == "view_more") { ActionValue = Slugs; } else if (Action == "show_web") { ActionValue = Link; } bool AtHome = ddlAtHome.SelectedValue.ToBool(); var newNotify = new NotifyNew() { CategoryID = CategoryID, CategorySlug = CategorySlug, Title = Title, Thumbnail = "", Summary = Summary, Content = Content, Action = Action, ActionValue = ActionValue, AtHome = AtHome, CreatedDate = currentDate, CreatedBy = acc.Username, ModifiedDate = currentDate, ModifiedBy = acc.Username, AppUpdate = currentDate }; var post = NotifyController.Insert(newNotify); //Phần thêm ảnh đại diện string path = "/uploads/images/posts/"; string Image = ""; if (PostPublicThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in PostPublicThumbnailImage.UploadedFiles) { var o = path + "notify-" + post.ID.ToString() + "-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); try { f.SaveAs(Server.MapPath(o)); Image = o; } catch { } } } string updateImage = NotifyController.UpdateImage(post.ID, Image); if (post != null) { PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo thông báo thành công", "s", true, "redirectTo(" + post.ID.ToString() + ")", Page); } } }