コード例 #1
0
        public JsonResult DeleteResume(Guid resumeId)
        {
            ProfileResumeViewModel VM = new ProfileResumeViewModel();

            try
            {
                JobApplicationAttachmentUploadItem deleteResumeFileItem = new JobApplicationAttachmentUploadItem();
                var res = _blConnector.GetMemberByEmail(this.Email);

                if (res.Member != null && res.Member.ResumeFiles != null)
                {
                    this.resumeList = JsonConvert.DeserializeObject <List <ProfileResumeJsonModel> >(res.Member.ResumeFiles);
                    var temp = resumeList.Where(x => x.Id == resumeId).FirstOrDefault();
                    if (temp != null)
                    {
                        deleteResumeFileItem.Id               = resumeId.ToString();
                        deleteResumeFileItem.AttachmentType   = JobApplicationAttachmentType.ProfileResume;
                        deleteResumeFileItem.FileName         = temp.FileName;
                        deleteResumeFileItem.PathToAttachment = temp.UploadPathToAttachment;
                        if (_jobApplicationService.DeleteFile(deleteResumeFileItem))
                        {
                            this.resumeList.Remove(temp);

                            res.Member.ResumeFiles = JsonConvert.SerializeObject(this.resumeList);

                            _blConnector.UpdateMember(res.Member);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                VM.DeleteError = true;
                Log.Write($"Unable to delete resume to the memeber profile. " + ex.Message, ConfigurationPolicy.ErrorLog);
            }

            VM.ResumeList = this.resumeList;
            VM.JsonData   = JsonConvert.SerializeObject(VM);
            var fullTemplateName = this.templateNamePrefix + this.TemplateName;

            return(new JsonResult {
                Data = VM
            });
        }