コード例 #1
0
        public void Remove(Guid id)
        {
            AppUserWork appUserWork = GetById(id);

            appUserWork.Status = DAL.Entity.Enum.Status.Deleted;
            Update(appUserWork);
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        public IActionResult EditJob(Guid id)
        {
            AppUserWork appUserWork = appUserWorkService.GetById(id);

            TempData["Logo"] = appUserWork.Logo;
            ViewBag.Logo     = TempData["Logo"].ToString();

            return(View(appUserWork));
        }
コード例 #5
0
 public void Update(AppUserWork entity)
 {
     context.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     context.SaveChanges();
 }
コード例 #6
0
 public void Add(AppUserWork entity)
 {
     context.AppUserWorks.Add(entity);
     context.SaveChanges();
 }
コード例 #7
0
 public IActionResult DeleteJob(AppUserWork appUserWork)
 {
     appUserWorkService.Remove(appUserWork.ID);
     return(RedirectToAction("MyJobs"));
 }