public async Task <bool> UpdateDraftAsync(MCredit_TempProfileAddModel model) { if (model == null || model.Id <= 0) { return(ToResponse(false, Errors.invalid_data)); } var profile = _mapper.Map <MCredit_TempProfile>(model); profile.UpdatedBy = _process.User.Id; profile.Status = _process.User.isAdmin ? model.Status : (int)MCreditProfileStatus.Submit; await _rpLog.InsertLog("mcredit-UpdateDraft", model.Dump()); var result = await _rpMCredit.UpdateDraftProfileAsync(profile); if (!result.success) { return(ToResponse(result)); } if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new NoteAddModel { UserId = _process.User.Id, ProfileId = model.Id, Content = model.LastNote, CommentTime = DateTime.Now, ProfileTypeId = (int)NoteType.MCreditTemp }; await _rpNote.AddNoteAsync(note); } return(true); }
public async Task <int> CreateDraftAsync(MCredit_TempProfileAddModel model) { if (model == null) { return(ToResponse(0, Errors.invalid_data)); } var profileExist = 0; if (!string.IsNullOrWhiteSpace(model.IdNumber)) { profileExist = await _rpMCredit.GetProfileIdByIdNumberAsync(model.IdNumber.Trim()); } else if (!string.IsNullOrWhiteSpace(model.CCCDNumber)) { profileExist = await _rpMCredit.GetProfileIdByIdNumberAsync(model.CCCDNumber.Trim()); } else { return(ToResponse(0, Errors.missing_cmnd)); } if (profileExist > 0) { return(ToResponse(0, Errors.id_number_has_exist)); } var profile = _mapper.Map <MCredit_TempProfile>(model); profile.CreatedBy = _process.User.Id; var response = await _rpMCredit.CreateDraftProfileAsync(profile); if (!response.success) { return(ToResponse(response)); } if (response.data > 0) { if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new NoteAddModel { CommentTime = DateTime.Now, Content = model.LastNote, ProfileId = response.data, ProfileTypeId = (int)NoteType.MCreditTemp, UserId = _process.User.Id }; await _rpNote.AddNoteAsync(note); } } return(response.data); }
public async Task <JsonResult> Create(MCredit_TempProfileAddModel model) { //var hoso = new HoSoBLL().LayChiTiet(Convert.ToInt32(model.Value)); //var obj = _mapper.Map<ProfileAddObj>(hoso); //obj.cityId = "58"; //obj.homeTown = "Bình Phước"; //obj.isAddr = true; //obj.loanPeriodCode = "3"; //obj.isInsurance = false; //obj.logSignCode = "28"; //obj.productCode = "C0000011"; //obj.saleID = "VBF0265"; //var result = await _svMCredit.CreateProfile(model, 3514); return(ToJsonResponse(true, "")); }
public async Task <JsonResult> UpdateDraft(MCredit_TempProfileAddModel model) { if (model == null || model.Id <= 0) { return(ToJsonResponse(false, "Dữ liệu không hợp lệ")); } var profile = _mapper.Map <MCredit_TempProfile>(model); profile.UpdatedBy = GlobalData.User.IDUser; var isAdmin = await _rpEmployee.CheckIsAdmin(GlobalData.User.IDUser); profile.Status = isAdmin ? model.Status: (int)MCreditProfileStatus.Submit; await _rpLog.InsertLog("mcredit-UpdateDraft", model.Dump()); var result = await _rpMCredit.UpdateDraftProfile(profile); if (!result) { return(ToJsonResponse(result, "Lỗi cập nhật")); } if (!string.IsNullOrWhiteSpace(model.LastNote)) { GhichuModel note = new GhichuModel { UserId = GlobalData.User.IDUser, HosoId = model.Id, Noidung = model.LastNote, CommentTime = DateTime.Now, TypeId = (int)NoteType.MCreditTemp }; await _rpNote.AddNoteAsync(note); } var peopleCanView = await _rpEmployee.GetPeopleIdCanViewMyProfile(GlobalData.User.IDUser); if (peopleCanView != null && peopleCanView.Any()) { peopleCanView.Add(GlobalData.User.IDUser); peopleCanView.Add(1); //admin var ids = string.Join(".", peopleCanView); await _rpMCredit.InsertPeopleWhoCanViewProfile(model.Id, ids); } //var obj = _mapper.Map<MCProfilePostModel>(profile); //var result = await _svMCredit.CreateProfile(obj, GlobalData.User.IDUser); return(ToJsonResponse(true, "")); }
public async Task <JsonResult> CreateDraft(MCredit_TempProfileAddModel model) { if (model == null) { return(ToJsonResponse(false, "Dữ liệu không hợp lệ")); } var profile = _mapper.Map <MCredit_TempProfile>(model); profile.CreatedBy = GlobalData.User.IDUser; var id = await _rpMCredit.CreateDraftProfile(profile); if (id > 0) { if (!string.IsNullOrWhiteSpace(model.LastNote)) { GhichuModel note = new GhichuModel { UserId = GlobalData.User.IDUser, HosoId = id, Noidung = model.LastNote, CommentTime = DateTime.Now, TypeId = (int)NoteType.MCreditTemp }; await _rpNote.AddNoteAsync(note); } var peopleCanView = await _rpEmployee.GetPeopleIdCanViewMyProfile(GlobalData.User.IDUser); if (peopleCanView != null && peopleCanView.Any()) { peopleCanView.Add(GlobalData.User.IDUser); peopleCanView.Add(1); //admin var ids = string.Join(".", peopleCanView); await _rpMCredit.InsertPeopleWhoCanViewProfile(id, ids); } } return(ToJsonResponse(true, "", id)); }
public async Task <IActionResult> SubmitToMCredit([FromBody] MCredit_TempProfileAddModel model) { var result = await _bizMCredit.SubmitToMCreditAsync(model, _hosting.ContentRootPath); return(ToResponse(result)); }
public async Task <IActionResult> UpdateDraft([FromBody] MCredit_TempProfileAddModel model) { var result = await _bizMCredit.UpdateDraftAsync(model); return(ToResponse(result)); }
public async Task <MCResponseModelBase> SubmitToMCreditAsync(MCredit_TempProfileAddModel model, string rootPath) { try { if (model == null || model.Id <= 0) { return(ToResponse <MCResponseModelBase>(null, Errors.invalid_data)); } if (model.SaleId <= 0) { return(ToResponse <MCResponseModelBase>(null, "Vui lòng chọn Sale")); } var profile = await _rpMCredit.GetTemProfileByIdAsync(model.Id); if (!profile.success) { return(ToResponse <MCResponseModelBase>(null, profile.error)); } if (profile.data == null) { return(ToResponse <MCResponseModelBase>(null, "Hồ sơ không tồn tại")); } var profileMC = _mapper.Map <MCProfilePostModel>(model); var files = await _rpFile.GetFilesByProfileIdAsync(model.Id, (int)ProfileType.MCredit); if (files == null || !files.Any()) { return(ToResponse <MCResponseModelBase>(null, "Vui lòng upload hồ sơ")); } var result = await _svMcredit.CreateProfile(profileMC); if (!result.success) { return(ToResponse <MCResponseModelBase>(null, result.error)); } if (result.data == null || string.IsNullOrWhiteSpace(result.data.id)) { return(ToResponse <MCResponseModelBase>(null, "Không thể gửi qua MC")); } await _rpMCredit.UpdateMCIdAsync(model.Id, result.data.id.Trim(), _process.User.Id); await _rpFile.UpdateFileMCProfileByIdAsync(model.Id, result.data.id); var bizMedia = _svProvider.GetService <IMediaBusiness>(); var zipFile = await bizMedia.ProcessFilesToSendToMC(profile.data.Id, $"{rootPath}/{Utility.FileUtils._profile_parent_folder}"); if (!zipFile.success) { return(ToResponse <MCResponseModelBase>(null, zipFile.result)); } var sendFileResult = await _svMcredit.SendFiles(zipFile.result, result.data.id); if (!sendFileResult.success) { return(ToResponse <MCResponseModelBase>(null, sendFileResult.error)); } await bizMedia.DeleteFile(zipFile.result); return(sendFileResult.data); } catch (Exception e) { var error = e.InnerException != null?e.InnerException.Dump() : e.Dump(); await _rpLog.InsertLog("SubmitToMCredit", error); return(ToResponse <MCResponseModelBase>(null, error)); } }
public async Task <JsonResult> SubmitToMCredit(MCredit_TempProfileAddModel model) { try { var isAdmin = await _rpEmployee.CheckIsAdmin(GlobalData.User.IDUser); if (!isAdmin) { return(ToJsonResponse(false, "Vui lòng liên hệ Admin")); } if (model == null || model.Id <= 0) { return(ToJsonResponse(false, "Dữ liệu không hợp lệ")); } if (model.SaleId <= 0) { return(ToJsonResponse(false, "Vui lòng chọn Sale")); } var profile = await _rpMCredit.GetTemProfileById(model.Id); if (profile == null) { return(ToJsonResponse(false, "Hồ sơ không tồn tại")); } var profileSql = _mapper.Map <MCredit_TempProfile>(model); profileSql.UpdatedBy = GlobalData.User.IDUser; var profileMC = _mapper.Map <MCProfilePostModel>(model); var files = await _rpTailieu.GetTailieuByHosoId(model.Id, (int)HosoType.MCredit); if (files == null || !files.Any()) { return(ToJsonResponse(false, "Vui lòng upload hồ sơ")); } var result = await _svMCredit.CreateProfile(profileMC, GlobalData.User.IDUser); if (result == null || result.status == "error") { return(ToJsonResponse(false, "", result)); } profileSql.MCId = result.id; profile.Status = (int)MCreditProfileStatus.SentToMc; await _rpMCredit.UpdateDraftProfile(profileSql); await _rpTailieu.UpdateTailieuHosoMCId(model.Id, result.id); var zipFile = await _bizMedia.ProcessFilesToSendToMC(model.Id, Server.MapPath($"~{Utility.FileUtils._profile_parent_folder}")); if (zipFile == "files_is_empty") { return(ToJsonResponse(false, "Vui lòng upload hồ sơ")); } var sendFileResult = await _svMCredit.SendFiles(GlobalData.User.IDUser, zipFile, result.id); return(ToJsonResponse(sendFileResult.status == "success" ? true : false, "", sendFileResult)); //return ToJsonResponse(true, "", new { file = zipFile, id = result.id }); } catch (Exception e) { await _rpLog.InsertLog("SubmitToMCredit", e.InnerException != null?e.InnerException.Dump() : e.Dump()); return(ToJsonResponse(false)); } }