public bool RemoveUser(int Id, int userId) { var user = _userRepositories.GetUser(Id); if (user != null) { user.IsDeleted = true; user.UpdatedBy = userId; user.UpdatedAt = DateTime.Now; _userRepositories.UpdateUser(user); return(true); } return(false); }
public async Task <ActionResult> EditPortfolio([FromForm] UserDto user) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); user.UserId = userId; if (user.CV.Length > 0) { Stream st = user.CV.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.PesronalCV = br.ReadBytes((int)user.CV.Length); } } if (user.PersonalImage.Length > 0) { Stream st = user.PersonalImage.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.PersonalImg = br.ReadBytes((int)user.PersonalImage.Length); } } if (user.ProjectDto[0].ProjectImage.Length > 0) { Stream st = user.ProjectDto[0].ProjectImage.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[0].ProjectImg = br.ReadBytes((int)user.ProjectDto[0].ProjectImage.Length); } } if (user.ProjectDto[1].ProjectImage.Length > 0) { Stream st = user.ProjectDto[1].ProjectImage.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[1].ProjectImg = br.ReadBytes((int)user.ProjectDto[1].ProjectImage.Length); } } if (user.ProjectDto[2].ProjectImage.Length > 0) { Stream st = user.ProjectDto[2].ProjectImage.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[2].ProjectImg = br.ReadBytes((int)user.ProjectDto[2].ProjectImage.Length); } } if (user.ProjectDto[0].ProjectPDF.Length > 0) { Stream st = user.ProjectDto[0].ProjectPDF.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[0].Projectpdf = br.ReadBytes((int)user.ProjectDto[0].ProjectPDF.Length); } } if (user.ProjectDto[1].ProjectPDF.Length > 0) { Stream st = user.ProjectDto[1].ProjectPDF.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[1].Projectpdf = br.ReadBytes((int)user.ProjectDto[1].ProjectPDF.Length); } } if (user.ProjectDto[2].ProjectPDF.Length > 0) { Stream st = user.ProjectDto[2].ProjectPDF.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { user.ProjectDto[2].Projectpdf = br.ReadBytes((int)user.ProjectDto[2].ProjectPDF.Length); } } userRepositories.UpdateUser(user); return(RedirectToAction("ShowPortfolio", "Show")); }