private void GetCapabilities() { HEWDataContext context = new HEWDataContext(); Capability capability = context.Capabilities.SingleOrDefault(); strCapital = capability.CapitalDevelopment; strNetAssets = capability.NetAssestsDevelopment; strStaff = capability.TotalEmployees; }
protected string GetRandomImg(int projectId, int count) { Random rd = new Random(); int rndImg = rd.Next(0, count); HEWDataContext context = new HEWDataContext(); return context.ProjectsImages.Where(i => i.ProjectID == projectId).Skip(rndImg).Take(1).SingleOrDefault(). ImgPublicID; }
private void RenderCapabilities() { HEWDataContext context = new HEWDataContext(); var cpabilitiesObj = context.Capabilities.SingleOrDefault(); if(cpabilitiesObj == null) return; txtAssetsDev.Text = cpabilitiesObj.NetAssestsDevelopment; txtCapitalDev.Text = cpabilitiesObj.CapitalDevelopment; txtStaff.Text = cpabilitiesObj.TotalEmployees; }
private void GetHomeNews() { HEWDataContext context = new HEWDataContext(); IEnumerable<New> homeNews = context.News.Where(i => i.IsPublished).OrderByDescending(i => i.PublishDate).Take(3).ToList(); foreach (var homeNew in homeNews) homeNew.Title = Helpers.TrimString(homeNew.Title + " ", 40); rptFooterNews.DataSource = homeNews; rptFooterNews.DataBind(); }
private void GetSideProjects() { HEWDataContext context = new HEWDataContext(); var result = (from pr in context.Projects where pr.IsSide && pr.ProjectsImages.Count > 0 select new { pr.ID, pr.Name, ImgsCount = pr.ProjectsImages.Count }).ToList(); rptSideProjects.DataSource = result; rptSideProjects.DataBind(); }
protected void btnDelete_Click(object sender, ImageClickEventArgs e) { ImageButton Delete = (ImageButton)sender; string IDVal = Delete.CommandArgument; int id = int.Parse(IDVal); HEWDataContext context = new HEWDataContext(); Model.New nNew = context.News.SingleOrDefault(i => i.ID == id); context.News.DeleteOnSubmit(nNew); context.SubmitChanges(); gvNews.DataBind(); }
private void EditProject(int projectId) { HEWDataContext context = new HEWDataContext(); var projectObj = context.Projects.SingleOrDefault(i => i.ID == projectId); projectObj.Name = txtName.Text.Trim(); projectObj.Description = txtDescription.Text.Trim(); projectObj.IsHome = cbIsHome.Checked; projectObj.IsSide = cbIsSideMenu.Checked; projectObj.CategoryID = Int16.Parse(ddlCategories.SelectedValue); context.SubmitChanges(); Response.Redirect(Request.RawUrl); }
private void AddNews() { HEWDataContext context = new HEWDataContext(); Model.New newsObj = new Model.New(); newsObj.Title = txtTitle.Text.Trim(); newsObj.Body = txtBody.Text.Trim(); newsObj.IsPublished = cbIsPublished.Checked; newsObj.PublishDate = Convert.ToDateTime(txtPublishDate.Text); newsObj.ImgPublicID = UploadImg(""); context.News.InsertOnSubmit(newsObj); context.SubmitChanges(); Response.Redirect("Default.aspx"); }
public void btnRegister_Click(object sender, EventArgs e) { HEWDataContext context = new HEWDataContext(); if (context.Newsletters.Any(i => i.Email == txtMail.Text.Trim())) { return; } Newsletter newsletter = new Newsletter{Email = txtMail.Text.Trim()}; context.Newsletters.InsertOnSubmit(newsletter); context.SubmitChanges(); txtMail.Text = string.Empty; }
private void AddProject() { HEWDataContext context = new HEWDataContext(); Project projectObj = new Project(); projectObj.Name = txtName.Text.Trim(); projectObj.Description = txtDescription.Text.Trim(); projectObj.IsHome = cbIsHome.Checked; projectObj.IsSide = cbIsSideMenu.Checked; projectObj.CategoryID = Int16.Parse(ddlCategories.SelectedValue); context.Projects.InsertOnSubmit(projectObj); context.SubmitChanges(); Response.Redirect("Default.aspx"); }
private void EditNews(int newsId) { HEWDataContext context = new HEWDataContext(); var newsObj = context.News.SingleOrDefault(i => i.ID == newsId); newsObj.Title = txtTitle.Text.Trim(); newsObj.Body = txtBody.Text.Trim(); newsObj.IsPublished = cbIsPublished.Checked; newsObj.PublishDate = Convert.ToDateTime(txtPublishDate.Text); if (hdnImage.Value != "") newsObj.ImgPublicID = UploadImg(""); context.SubmitChanges(); Response.Redirect(Request.RawUrl); }
private void EditVacancy(int vacancyId) { HEWDataContext context = new HEWDataContext(); var vacancyObj = context.Vacancies.SingleOrDefault(i => i.ID == vacancyId); vacancyObj.Vacancy1 = txtVacancy.Text.Trim(); vacancyObj.Location = txtLocation.Text.Trim(); vacancyObj.IsPublished = cbIsPublished.Checked; vacancyObj.OpeningDate = Convert.ToDateTime(txtOpeningDate.Text); vacancyObj.JobDescription = txtDescription.Text.Trim(); vacancyObj.RequiredSkills = txtSkills.Text.Trim(); vacancyObj.Openings = Int16.Parse(txtOpenings.Text.Trim()); vacancyObj.CategoryID = int.Parse(ddlCategories.SelectedValue); context.SubmitChanges(); Response.Redirect(Request.RawUrl); }
protected void btnDelete_Click(object sender, EventArgs e) { LinkButton Delete = (LinkButton)sender; string imageID = Delete.CommandArgument; HEWDataContext context = new HEWDataContext(); ProjectsImage image = context.ProjectsImages.SingleOrDefault(i=>i.ID == int.Parse(imageID)); Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE"); Cloudinary cloudinary = new Cloudinary(account); cloudinary.DeleteResources(new [] {image.ImgPublicID}); context.ProjectsImages.DeleteOnSubmit(image); context.SubmitChanges(); rptImages.DataBind(); }
private void AddVacany() { HEWDataContext context = new HEWDataContext(); Vacancy vacancyObj = new Vacancy(); vacancyObj.Vacancy1 = txtVacancy.Text.Trim(); vacancyObj.Location = txtLocation.Text.Trim(); vacancyObj.IsPublished = cbIsPublished.Checked; vacancyObj.OpeningDate = Convert.ToDateTime(txtOpeningDate.Text); vacancyObj.JobDescription = txtDescription.Text.Trim(); vacancyObj.RequiredSkills = txtSkills.Text.Trim(); vacancyObj.Openings = Int16.Parse(txtOpenings.Text.Trim()); vacancyObj.CategoryID = int.Parse(ddlCategories.SelectedValue); context.Vacancies.InsertOnSubmit(vacancyObj); context.SubmitChanges(); Response.Redirect("Default.aspx"); }
protected void btnDelete_Click(object sender, ImageClickEventArgs e) { ImageButton Delete = (ImageButton)sender; string IDVal = Delete.CommandArgument; int id = int.Parse(IDVal); HEWDataContext context = new HEWDataContext(); Project project = context.Projects.SingleOrDefault(i => i.ID == id); IEnumerable<ProjectsImage> images = context.ProjectsImages.Where(i => i.ProjectID == id); CloudinaryDotNet.Account account = new CloudinaryDotNet.Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE"); CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account); cloudinary.DeleteResources(images.Select(i => i.ImgPublicID).ToArray()); context.ProjectsImages.DeleteAllOnSubmit(images); context.Projects.DeleteOnSubmit(project); context.SubmitChanges(); gvProjects.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { bool isInsert = false; HEWDataContext context = new HEWDataContext(); var cpabilitiesObj = context.Capabilities.SingleOrDefault(); if (cpabilitiesObj == null) { cpabilitiesObj = new Capability(); isInsert = true; } cpabilitiesObj.CapitalDevelopment = txtCapitalDev.Text.Trim(); cpabilitiesObj.NetAssestsDevelopment = txtAssetsDev.Text.Trim(); cpabilitiesObj.TotalEmployees = txtStaff.Text.Trim(); if(isInsert) context.Capabilities.InsertOnSubmit(cpabilitiesObj); context.SubmitChanges(); Response.Redirect(Request.RawUrl); }
protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { try { Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE"); Cloudinary cloudinary = new Cloudinary(account); ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription("file", new MemoryStream(e.GetContents())) }; ImageUploadResult uploadResult = cloudinary.Upload(uploadParams); HEWDataContext context = new HEWDataContext(); context.ProjectsImages.InsertOnSubmit(new ProjectsImage {ImgPublicID = uploadResult.PublicId, ProjectID = int.Parse(Request.QueryString["ProjectID"])}); context.SubmitChanges(); } catch (Exception) { } }
private void GetRegisteredUsers() { HEWDataContext context = new HEWDataContext(); strRegisteredUsers = context.Newsletters.Count().ToString(); }