Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAddAsync()
        {
            var _files = HttpContext.Request.Form.Files;
            var _file  = (_files.Count > 0)?_files[0]:null;

            if (_file == null)
            {
                ModelState.AddModelError("_form.picture", "Please cloose a picture file");
                return(await OnGetAsync());
            }
            if (!_upload.IsFileValid(_file))
            {
                ModelState.AddModelError("_form.picture", _upload.errorMessage);
            }

            if (!ModelState.IsValid)
            {
                return(await OnGetAsync());
            }

            AppUser _originalUser = await _db.UserTable.FirstOrDefaultAsync(m => m.Id == _manager.GetUserId(User));

            if (_originalUser.picture != null)
            {
                _upload.DeleteFile(_originalUser.picture);
            }

            _originalUser.picture = _upload.UploadFile(_file);
            await Change(_originalUser);

            return(RedirectToPage("./profile", new { id = _originalUser.Id }));
        }
Ejemplo n.º 2
0
        public async Task <object> DeleteCV([FromForm] ListCVOfCandidate dataDelete)
        {
            UploadImage uploadImage = new UploadImage(_hostEnvironment);
            string      pathCV      = await uploadImage.DeleteFile(dataDelete.PathCV);

            var           identity = HttpContext.User.Identity as ClaimsIdentity;
            IList <Claim> claims   = identity.Claims.ToList();
            var           result   = await _context.Database.ExecuteSqlRawAsync("dbo.UTE_Seeker_DeleteCV " +
                                                                                "@CandidateCode={0},@RecID={1}",
                                                                                claims[5].Value,
                                                                                dataDelete.RecID
                                                                                );

            IActionResult response = Unauthorized();

            if (result > 0)
            {
                response = Ok(new { Error = "" });
                return(response);
            }
            response = Ok(new { Error = "Có lỗi" });
            return(response);
        }
Ejemplo n.º 3
0
        public async Task <object> UploadCV([FromForm] UpLoadCV fileCV)
        {
            UploadImage uploadImage = new UploadImage(_hostEnvironment);
            string      pathCV      = null;

            if (fileCV.CVFile != null)
            {
                pathCV = await uploadImage.SaveImage(fileCV.CVFile);
            }
            if (fileCV.OrdinalCVName != null && fileCV.CVFile != null)
            {
                await uploadImage.DeleteFile(fileCV.OrdinalCVName);
            }

            var           identity = HttpContext.User.Identity as ClaimsIdentity;
            IList <Claim> claims   = identity.Claims.ToList();
            var           result   = await _context.Database.ExecuteSqlRawAsync("dbo.UTE_Seeker_InsertOrUpdateCV " +
                                                                                "@CandidateCode={0},@PathCV={1},@RecID={2},@JobTitleID={3}," +
                                                                                "@Description={4},@IsPublic={5}",
                                                                                claims[5].Value,
                                                                                pathCV,
                                                                                fileCV.RecID,
                                                                                fileCV.JobTitleID,
                                                                                fileCV.Description,
                                                                                fileCV.IsPublic
                                                                                );

            IActionResult response = Unauthorized();

            if (result > 0)
            {
                response = Ok(new { Error = "" });
                return(response);
            }
            response = Ok(new { Error = "Có lỗi" });
            return(response);
        }