public void AddDateTimeToDb(UrlsDatesMapping urlDatemapping) { if (urlDatemapping != null) { _db.UrlsDatesMapping.Add(urlDatemapping); _db.SaveChanges(); } }
protected void SaveDateTime(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txt_Date.Text)) { var idUrl = Guid.NewGuid().ToString(); idUrl = Regex.Replace(idUrl, "-", string.Empty, RegexOptions.IgnoreCase); var urlDateMapping = new UrlsDatesMapping { IdUrl = idUrl, EventDateTime = DateTime.Parse(txt_Date.Text) }; DBActions dbAction = new DBActions(); dbAction.AddDateTimeToDb(urlDateMapping); var currentUrl = HttpContext.Current.Request.Url; string urlGenerated = currentUrl.Scheme + "://" + currentUrl.Authority + "/" + idUrl; UrlGenerated.Text = urlGenerated; ModalPanel.Visible = true; } }