public IActionResult Edit(OnlineJobSite o) { if (ModelState.IsValid) { this.onlineRepo.Edit(o); return(RedirectToAction("Index")); } return(View()); }
public IActionResult EditWithCourse([FromBody] OnlineJobSite t) { if (ModelState.IsValid) { if (repo.Update(t)) { return(Json(new { success = true })); } } return(Json(new { success = false })); }
public IActionResult Create(OnlineJobSite t) { if (ModelState.IsValid) { if (repo.Insert(t)) { return(RedirectToAction("Create", new { postBack = "postBack" })); } } return(View(t)); }
public IHttpActionResult GetOnlineJobSite(int id) { OnlineJobSite onlineJobSite = db.OnlineJobSites.Find(id); if (onlineJobSite == null) { return(NotFound()); } return(Ok(onlineJobSite)); }
public IHttpActionResult PostOnlineJobSite(OnlineJobSite onlineJobSite) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} db.OnlineJobSites.Add(onlineJobSite); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = onlineJobSite.OnlineJobSiteId }, onlineJobSite)); }
public IHttpActionResult DeleteOnlineJobSite(int id) { OnlineJobSite onlineJobSite = db.OnlineJobSites.Find(id); if (onlineJobSite == null) { return(NotFound()); } db.OnlineJobSites.Remove(onlineJobSite); db.SaveChanges(); return(Ok(onlineJobSite)); }
public JsonResult CreateTradeWithCourse([FromBody] OnlineJobSite t) { if (ModelState.IsValid) { if (repo.Insert(t)) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } } else { return(Json(new { success = false })); } //return View(); }
protected override void Seed(MVC_Project_Work_02.Models.JobDbContext context) { OnlineJobSite o = new OnlineJobSite { OnlineJobSiteName = "Bdjobs", StartedJourney = DateTime.Parse("2012-02-04").Date, Web = "https://www.bdjobs.com", Response = true }; o.JobAdvertisements.Add(new JobAdvertisement { JobAdvertisementName = "Future Leader", Post = JobType.MTO }); o.JobAdvertisements.Add(new JobAdvertisement { JobAdvertisementName = "SPO Cader", Post = JobType.Senior }); o.RegisterApplicants.Add(new RegisterApplicant { RegisterApplicantName = "Natasha", ContactEmail = "*****@*****.**" }); o.RegisterApplicants.Add(new RegisterApplicant { RegisterApplicantName = "Rouza", ContactEmail = "*****@*****.**" }); OnlineJobSite o1 = new OnlineJobSite { OnlineJobSiteName = "Kormo", StartedJourney = DateTime.Parse("2014-03-09").Date, Web = "https://www.kormo.com", Response = false }; o1.JobAdvertisements.Add(new JobAdvertisement { JobAdvertisementName = "It Consultant", Post = JobType.ItProfessional }); o1.JobAdvertisements.Add(new JobAdvertisement { JobAdvertisementName = "It Officer", Post = JobType.Junior }); o1.RegisterApplicants.Add(new RegisterApplicant { RegisterApplicantName = "Ahmed", ContactEmail = "*****@*****.**" }); o1.RegisterApplicants.Add(new RegisterApplicant { RegisterApplicantName = "Masud", ContactEmail = "*****@*****.**" }); context.OnlineJobSites.Add(o); context.OnlineJobSites.Add(o1); context.SaveChanges(); }
public bool Update(OnlineJobSite oj, bool childIncluded = false) { // db.Entry(trade).State = EntityState.Modified; var orignal = db.OnlineJobSites.Include(x => x.JobAdvertisements).First(x => x.OnlineJobSiteId == oj.OnlineJobSiteId); orignal.OnlineJobSiteName = oj.OnlineJobSiteName; orignal.StartedJourney = oj.StartedJourney; orignal.Web = oj.Web; if (oj.JobAdvertisements != null && oj.JobAdvertisements.Count > 0) { var courses = oj.JobAdvertisements.ToArray(); for (var i = 0; i < courses.Length; i++) { var temp = orignal.JobAdvertisements.FirstOrDefault(c => c.JobAdvertisementId == courses[i].JobAdvertisementId); if (temp != null) { temp.JobTypeName = courses[i].JobTypeName; temp.Responsibility = courses[i].Responsibility; } else { orignal.JobAdvertisements.Add(courses[i]); } } foreach (var c in orignal.JobAdvertisements) { var temp = oj.JobAdvertisements.FirstOrDefault(t => t.JobAdvertisementId == c.JobAdvertisementId); if (temp == null) { db.Entry(c).State = EntityState.Deleted; } } } return(db.SaveChanges() > 0); }
public void Insert(OnlineJobSite o) { db.OnlineJobSites.Add(o); db.SaveChanges(); }
public void Edit(OnlineJobSite o) { db.Entry(o).State = EntityState.Modified; db.SaveChanges(); }
public bool Insert(OnlineJobSite oj) { db.OnlineJobSites.Add(oj); return(db.SaveChanges() > 0); }
public IHttpActionResult PutOnlineJobSite(int id, OnlineJobSite onlineJobSite) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != onlineJobSite.OnlineJobSiteId) { return(BadRequest()); } var ext = db.OnlineJobSites.Include(x => x.JobAdvertisements).Include(y => y.RegisterApplicants).First(x => x.OnlineJobSiteId == onlineJobSite.OnlineJobSiteId); ext.OnlineJobSiteName = onlineJobSite.OnlineJobSiteName; ext.StartedJourney = onlineJobSite.StartedJourney; ext.Web = onlineJobSite.Web; ext.Response = onlineJobSite.Response; if (onlineJobSite.JobAdvertisements != null && onlineJobSite.JobAdvertisements.Count > 0) { var prs = onlineJobSite.JobAdvertisements.ToArray(); for (var i = 0; i < prs.Length; i++) { var temp = ext.JobAdvertisements.FirstOrDefault(c => c.JobAdvertisementId == prs[i].JobAdvertisementId); if (temp != null) { temp.JobAdvertisementName = prs[i].JobAdvertisementName; temp.Post = prs[i].Post; } else { ext.JobAdvertisements.Add(prs[i]); } } prs = ext.JobAdvertisements.ToArray(); for (var i = 0; i < prs.Length; i++) { var temp = onlineJobSite.JobAdvertisements.FirstOrDefault(x => x.JobAdvertisementId == prs[i].JobAdvertisementId); if (temp == null) { db.Entry(prs[i]).State = EntityState.Deleted; } } } if (onlineJobSite.RegisterApplicants != null && onlineJobSite.RegisterApplicants.Count > 0) { var srvs = onlineJobSite.RegisterApplicants.ToArray(); for (var i = 0; i < srvs.Length; i++) { var temp = ext.RegisterApplicants.FirstOrDefault(c => c.RegisterApplicantId == srvs[i].RegisterApplicantId); if (temp != null) { temp.RegisterApplicantName = srvs[i].RegisterApplicantName; temp.ContactEmail = srvs[i].ContactEmail; } else { ext.RegisterApplicants.Add(srvs[i]); } } srvs = ext.RegisterApplicants.ToArray(); for (var i = 0; i < srvs.Length; i++) { var temp = onlineJobSite.RegisterApplicants.FirstOrDefault(x => x.RegisterApplicantId == srvs[i].RegisterApplicantId); if (temp == null) { db.Entry(srvs[i]).State = EntityState.Deleted; } } } try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OnlineJobSiteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }