public void Remove(Guid id) { AppUserWork appUserWork = GetById(id); appUserWork.Status = DAL.Entity.Enum.Status.Deleted; Update(appUserWork); }
public async Task <IActionResult> EditJob(AppUserWork model, IFormFile logo) { AppUser user = userManager.FindByNameAsync(User.Identity.Name).Result; try { string path; if (model.Logo == null) { if (model.Logo != null) { appUserWorkService.Update(model); return(RedirectToAction("MyJobs")); } path = Path.Combine(Directory.GetCurrentDirectory(), TempData["Logo"].ToString()); model.Logo = TempData["Logo"].ToString(); } else { path = Path.GetFullPath("wwwroot\\logos" + logo.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await logo.CopyToAsync(stream); } model.Logo = logo.FileName; } model.AppUserId = user.Id; appUserWorkService.Update(model); return(RedirectToAction("MyJobs")); } catch (Exception ex) { throw; } }
public async Task <IActionResult> PostJob(AppUserWork model, IFormFile logo) { AppUser user = userManager.FindByNameAsync(User.Identity.Name).Result; try { string path; if (logo == null) { path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\logos", "nologo.png"); model.Logo = "nologo.png"; } else { path = Path.GetFullPath("wwwroot\\logos\\" + logo.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await logo.CopyToAsync(stream); } model.Logo = logo.FileName; } var iduser = await userManager.FindByIdAsync(user.Id.ToString()); model.AppUser = iduser; model.AppUserId = iduser.Id; appUserWorkService.Add(model); return(RedirectToAction("Jobs")); } catch (Exception ex) { return(View(model)); } }
public IActionResult EditJob(Guid id) { AppUserWork appUserWork = appUserWorkService.GetById(id); TempData["Logo"] = appUserWork.Logo; ViewBag.Logo = TempData["Logo"].ToString(); return(View(appUserWork)); }
public void Update(AppUserWork entity) { context.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }
public void Add(AppUserWork entity) { context.AppUserWorks.Add(entity); context.SaveChanges(); }
public IActionResult DeleteJob(AppUserWork appUserWork) { appUserWorkService.Remove(appUserWork.ID); return(RedirectToAction("MyJobs")); }