public ActionResult Create(PostJob model) { var userid = User.Identity.GetUserId(); DateTime date = DateTime.Now; try { model.IsStillAvilavble = true; model.IsAvilavbleAtWall = true; model.NumberOfSubmitted = 0; model.Rate = 1; model.CreationDate = date; model.UserName = User.Identity.GetUserName(); model.UserId = userid; postJobRepository.CreatePost(model); postJobRepository.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <IActionResult> EditJob(int?id, PostJob post) { ViewBag.City = _db.Cities.ToList(); ViewBag.JobCategory = _db.JobCategories.ToList(); AppUser user = await _userManager.FindByNameAsync(User.Identity.Name); if (!ModelState.IsValid) { return(View()); } PostJob dbPost = await _db.PostJobs.FindAsync(id); dbPost.JobDescription = post.JobDescription; dbPost.JobTitle = post.JobTitle; dbPost.CityId = post.CityId; dbPost.JobCategoryId = post.JobCategoryId; dbPost.CompanyName = post.CompanyName; dbPost.RequiredExperience = post.RequiredExperience; dbPost.Salary = post.Salary; dbPost.JobType = post.JobType; dbPost.Skills = post.Skills; dbPost.AppUserId = user.Id; await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> PostJob(PostJob post) { ViewBag.City = _db.Cities.ToList(); ViewBag.JobCategory = _db.JobCategories.ToList(); AppUser user = await _userManager.FindByNameAsync(User.Identity.Name); if (!ModelState.IsValid) { return(View()); } PostJob newPost = new PostJob(); newPost.JobDescription = post.JobDescription; newPost.JobTitle = post.JobTitle; newPost.CityId = post.CityId; newPost.JobCategoryId = post.JobCategoryId; newPost.RequiredExperience = post.RequiredExperience; newPost.Salary = post.Salary; newPost.CreateTime = DateTime.Now; newPost.ExpiresDate = post.ExpiresDate; newPost.JobType = post.JobType; newPost.Image = user.Image; newPost.Skills = post.Skills; newPost.AppUserId = user.Id; await _db.PostJobs.AddAsync(newPost); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(PostJob model) { var post = postJobRepository.GetPostJobById(model.Id); DateTime date = DateTime.Now; if (post == null) { return(HttpNotFound()); } try { post.IsStillAvilavble = true; post.IsAvilavbleAtWall = true; post.JobBudget = model.JobBudget; post.JobType = model.JobType; post.CreationDate = date; postJobRepository.EditPost(post); postJobRepository.Save(); return(RedirectToAction("Index")); } catch (Exception) { } return(View()); }
public async Task <ActionResult> Edit(PostJob model) { var post = await _db.PostJobs.FirstOrDefaultAsync(p => p.Id == model.Id); DateTime date = DateTime.Now; if (post == null) { return(HttpNotFound()); } try { post.IsStillAvilavble = true; post.IsAvilavbleAtWall = true; post.JobBudget = model.JobBudget; post.JobType = model.JobType; post.CreationDate = date; await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception) { } return(View()); }
public IActionResult Delete(int?id) { if (id == null) { return(NotFound()); } PostJob postJob = _db.PostJobs.FirstOrDefault(x => x.Id == id); if (postJob == null) { return(NotFound()); } return(View(postJob)); }
public async Task <IActionResult> EditJob(int?id) { ViewBag.City = _db.Cities.ToList(); ViewBag.JobCategory = _db.JobCategories.ToList(); if (id == null) { return(RedirectToAction("Index", "Error404")); } PostJob job = await _db.PostJobs.FindAsync(id); if (job == null) { return(RedirectToAction("Index", "Error404")); } return(View(job)); }
public async Task <IActionResult> DeleteJob(int?id, PostJob job) { if (id == null) { return(RedirectToAction("Index", "Error404")); } PostJob dbJob = await _db.PostJobs.FindAsync(id); if (dbJob == null) { return(RedirectToAction("Index", "Error404")); } _db.PostJobs.Remove(dbJob); await _db.SaveChangesAsync(); return(RedirectToAction("MyJobList", "Users")); }
public async Task <IActionResult> DeletePost(int?id) { if (id == null) { return(NotFound()); } PostJob postJob = _db.PostJobs.FirstOrDefault(x => x.Id == id); if (postJob == null) { return(NotFound()); } _db.PostJobs.Remove(postJob); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Deactive(int?id, bool IsActivated) { if (id == null) { return(RedirectToAction("Index", "Error404")); } PostJob job = await _db.PostJobs.FindAsync(id); if (job == null) { return(RedirectToAction("Index", "Error404")); } job.IsActivated = !IsActivated; await _db.SaveChangesAsync(); return(RedirectToAction("MyJobList", "Users")); }
public async Task <IActionResult> AddApply(int?id) { PostJob postJob = _db.PostJobs.Include(x => x.AppUserPostJobs).FirstOrDefault(x => x.Id == id); AppUser user = await _userManager.FindByNameAsync(User.Identity.Name); ViewBag.activeUser = user; if (user.AppUserPostJobs == null) { AppUserPostJob appUserPost = new AppUserPostJob { AppUserId = postJob.AppUserId, AppendUserId = user.Id, PostJobId = postJob.Id, IsContacted = true }; _db.AppUserPostJobs.Add(appUserPost); } await _db.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> RateJob(PostJob model) { var post = postJobRepository.GetPostJobById(model.Id); var userID = User.Identity.GetUserId(); if (post == null) { return(HttpNotFound()); } StarRating rating = new StarRating(); PostJob postfromDb = new PostJob(); var IsRatingBefore = await _db.Stars.FirstOrDefaultAsync(r => r.PostId == model.Id && r.UserId == userID); if (IsRatingBefore != null) { ViewBag.AlreadyRatedMessage = "You have already Rate this job"; } else { rating.PostId = model.Id; rating.UserId = userID; rating.Rating = model.Rate; postfromDb = _db.PostJobs.Find(model.Id); postfromDb.Rate = (postfromDb.Rate + rating.Rating) / 2; _db.Stars.Add(rating); _db.Entry(postfromDb).State = EntityState.Modified; await _db.SaveChangesAsync(); return(RedirectToAction("Index", "Posts", new { area = "" })); } return(View(post)); }
public ActionResult PostJob(PostJob postJob) { bool Status = false; string Message = ""; // //Model Validation if (ModelState.IsValid) { db.PostJobs.Add(postJob); db.SaveChanges(); Message = "Registration successfully done. Account Activation Link" + " has been sent to your Email Address: "; Status = true; return(View(postJob)); } else { Message = "Invalid Request"; } ViewBag.Message = Message; ViewBag.Status = Status; return(View(postJob)); }
public async Task <ActionResult> Create(PostJob model) { var userid = User.Identity.GetUserId(); DateTime date = DateTime.Now; try { model.IsStillAvilavble = false; model.IsAvilavbleAtWall = true; model.NumberOfSubmitted = 0; model.Rate = 1; model.CreationDate = date; model.UserName = User.Identity.GetUserName(); model.UserId = userid; _db.PostJobs.Add(model); await _db.SaveChangesAsync(); return(RedirectToAction("Index", "Home", new { area = "" })); } catch { return(View()); } }
public void EditPost(PostJob post) { _db.Entry(post).State = EntityState.Modified; }
public void DeltePost(PostJob post) { _db.PostJobs.Remove(post); }
public void CreatePost(PostJob post) { _db.PostJobs.Add(post); }