protected void btnUpdate_Click(object sender, EventArgs e) { if (hddID.Value == "") { return; } ZoneInfo info = ZoneDB.GetInfo(ConvertUtility.ToInt32(hddID.Value)); if (info == null) { Reset(); return; } if (txtName.Text.Trim() == "") { lblStatusUpdate.Text = AppEnv.NoticeRequired(lang, "TÊN MỤC"); return; } info.Zone_ParentID = ConvertUtility.ToInt32(dropZones.SelectedValue); info.Zone_Name = txtName.Text.Trim(); info.Zone_Description = txtDescriptionCK.HtmlValue; info.Zone_FriendlyUrl = txtFriendlyUrl.Text.Replace(" ", ""); info.Zone_RealUrl = txtRealUrl.Text.Trim(); info.Zone_Avatar = txtAvatar.Text.Trim(); //priority field info.Zone_Lang = lang; if (info.Zone_ID == info.Zone_ParentID) { lblStatusUpdate.Text = "<font color='red'>" + (lang == "vi-VN" ? " Trùng mục cha, chọn mục cha khác !" : "The same Index Parent,Select other index Parent !") + "</font>"; return; } if (ZoneDB.Update(info)) { lblStatusUpdate.Text = AppEnv.NoticeEdit(lang, true); hddID.Value = ""; btnUpdate.Enabled = false; btnDelete.Enabled = false; Reset(); } else { lblStatusUpdate.Text = AppEnv.NoticeEdit(lang, false); } LoadZones(); }
public async Task <Element> UpdateElementAsync(Element element) { try { Element oldElem; if ((oldElem = await context.Elements .Where(z => z.ElementId == element.ElementId).SingleOrDefaultAsync()) != null) { if (element.ElementId != null) { oldElem.ElementId = element.ElementId; } if (element.ElementType != null) { oldElem.ElementType = element.ElementType; } if (element.Info != null) { oldElem.Info = element.Info; } if (element.GeoJson != null) { oldElem.GeoJson = element.GeoJson; } context.Update(oldElem); await context.SaveChangesAsync(); return(oldElem); } throw new ArgumentException("Invalid element provided"); } catch (Exception) { throw new ArgumentException("Invalid element provided"); } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (hddID.Value == "") { return; } ZoneInfo info = ZoneDB.GetInfo(ConvertUtility.ToInt32(hddID.Value)); if (info == null) { Reset(); return; } if (txtName.Text.Trim() == "") { lblStatusUpdate.Text = AppEnv.NoticeRequired(lang, "TÊN MỤC"); return; } info.Zone_ParentID = ConvertUtility.ToInt32(dropZones.SelectedValue); info.Zone_Name = txtName.Text.Trim(); info.Zone_Description = txtDescription.Text; info.Zone_FriendlyUrl = UnicodeUtility.UnicodeToFriendlyUrl(txtName.Text); info.Zone_RealUrl = txtRealUrl.Text.Trim(); info.Zone_Avatar = txtAvatar.Text.Trim(); //priority field info.Zone_MetaDescription = txtDescription.Text; info.Zone_MetaKeywords = txtMetaKeywords.Text; info.Zone_Layout = dropLayout.SelectedValue; info.Zone_SubcategoryDisplay = dropSubcategoryDisplay.SelectedValue; info.Zone_ContentListingDisplay = dropContentDisplay.SelectedValue; info.Zone_VisibleInMainNav = chkMainNav.Checked; info.Zone_VisibleInLeftNav = chkLeftNav.Checked; info.Zone_VisibleInTopNav = chkTopNav.Checked; info.Zone_VisibleInFooterNav = chkFooterNav.Checked; info.Zone_ExcludeFromNav = chkExcludeFromNav.Checked; info.Zone_Visible = chkVisible.Checked; info.Zone_Disable = chkDisable.Checked; info.Zone_Lang = lang; if (info.Zone_ID == info.Zone_ParentID) { lblStatusUpdate.Text = "<font color='red'>" + (lang == "vi-VN" ? " Trùng mục cha, chọn mục cha khác !" : "The same Index Parent,Select other index Parent !") + "</font>"; return; } if (ZoneDB.Update(info)) { lblStatusUpdate.Text = AppEnv.NoticeEdit(lang, true); hddID.Value = ""; btnUpdate.Enabled = false; btnDelete.Enabled = false; Reset(); } else { lblStatusUpdate.Text = AppEnv.NoticeEdit(lang, false); } LoadZones(); }