private async Task <bool> InsertHosoFromFile(HosoCourier hoso, IHosoCourrierRepository _rpCourrier) { var id = await _rpCourrier.Create(hoso); if (!string.IsNullOrWhiteSpace(hoso.LastNote)) { var note = new GhichuModel { Noidung = hoso.LastNote, HosoId = id, UserId = GlobalData.User.IDUser, TypeId = (int)NoteType.HosoCourrier }; await _rpNote.AddNoteAsync(note); } if (hoso.AssigneeIds == null || !hoso.AssigneeIds.Any()) { hoso.AssigneeIds = new List <int>(); } hoso.AssigneeIds.Add(GlobalData.User.IDUser); hoso.AssigneeIds.Add(1);//Thainm var tasks = new List <Task>(); foreach (var assingeeId in hoso.AssigneeIds) { tasks.Add(_rpCourrier.InsertCourierAssignee(id, assingeeId)); } await Task.WhenAll(tasks); return(true); }
public async Task <ActionResult> Update(Company model) { if (model == null) { return(ToResponse(false, "Dữ liệu không hợp lệ")); } var bizCompany = new CompanyRepository(); var result = await bizCompany.UpdateAsync(model); if (!result) { return(ToResponse(false)); } if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new GhichuModel { Noidung = model.LastNote, HosoId = model.Id, TypeId = (int)NoteType.Company, UserId = GlobalData.User.IDUser }; await _rpNote.AddNoteAsync(note); } return(ToResponse(true)); }
public async Task <BaseResponse <int> > CreateAsync(CheckDupAddModel model, int createdBy) { if (model.PartnerId <= 0) { return(ToResponse(0, false, "Vui lòng chọn đối tác")); } var obj = _mapper.Map <CheckDupAddSql>(model); obj.CICStatus = (int)CheckDupCICStatus.NotDebt; obj.PartnerStatus = (int)CheckDupPartnerStatus.NotCheck; var response = await _rpCheckDup.CreateAsync(obj, createdBy); if (response.data > 0) { if (!string.IsNullOrWhiteSpace(model.Note)) { var note = new GhichuModel { Noidung = model.Note, HosoId = response.data, CommentTime = DateTime.Now, TypeId = (int)NoteType.CheckDup }; await _rpNote.AddNoteAsync(note); } return(ToResponse(response.data)); } return(ToResponse(0, false, response.error)); }
public async Task <BaseResponse <bool> > UpdateAsync(CheckDupEditModel model, int updatedBy) { if (model == null) { return(ToResponse(false, false, "Dữ liệu không hợp lệ")); } if (model.PartnerId <= 0) { return(ToResponse(false, false, "Vui lòng chọn đối tác")); } var checkDup = _mapper.Map <CheckDupAddSql>(model); var result = await _rpCheckDup.UpdateAsync(checkDup, updatedBy); if (!result.success) { return(ToResponse(result)); } if (!string.IsNullOrWhiteSpace(model.Note)) { var note = new GhichuModel { Noidung = model.Note, HosoId = checkDup.Id, CommentTime = DateTime.Now, TypeId = (int)NoteType.CheckDup }; await _rpNote.AddNoteAsync(note); } return(ToResponse(true)); }
public async Task AddNoteAsync(GhichuModel model) { using (var con = GetConnection()) { await con.ExecuteAsync("insert into Ghichu (UserId,Noidung,HosoId, CommentTime,TypeId) values(@userId,@noidung,@hosoId,@commentTime,@typeId)", new { userId = model.UserId, noidung = model.Noidung, hosoId = model.HosoId, commentTime = DateTime.Now, typeId = model.TypeId }, commandType : CommandType.Text); } }
private async Task <bool> AddGhichu(int hosoId, string ghiChu) { GhichuModel ghichu = new GhichuModel { UserId = GlobalData.User.IDUser, HosoId = hosoId, Noidung = ghiChu, CommentTime = DateTime.Now, TypeId = (int)NoteType.Hoso }; await _rpNote.AddNoteAsync(ghichu); return(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 <ActionResult> Create(Company model) { var _bizCompany = new CompanyRepository(); var id = await _bizCompany.CreateAsync(model); if (id > 0) { if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new GhichuModel { Noidung = model.LastNote, HosoId = id, TypeId = (int)NoteType.Company, UserId = GlobalData.User.IDUser }; await _rpNote.AddNoteAsync(note); } return(ToResponse(true)); } return(ToResponse(false)); }
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 <ActionResult> Update(HosoCorrierRequestModel model) { if (model == null || model.Id <= 0) { return(ToResponse(false, "Dữ liệu không hợp lệ")); } if (string.IsNullOrWhiteSpace(model.CustomerName)) { return(ToResponse(false, "Tên khách hàng không được để trống")); } if (model.AssignId <= 0) { return(ToResponse(false, "Vui lòng chọn courier")); } var profile = await _rpCourierProfile.GetById(model.Id); if (profile == null) { return(ToJsonResponse(false, "Hồ sơ không tồn tại")); } bool isAdmin = await _rpEmployee.CheckIsAdmin(GlobalData.User.IDUser); if (profile.Status == (int)TrangThaiHoSo.Cancel) { if (!isAdmin) { return(ToJsonResponse(false, "Bạn không có quyền, vui lòng liên hệ Admin")); } } var sale = null as OptionSimple; var hoso = new HosoCourier { CustomerName = model.CustomerName, Cmnd = model.Cmnd, Status = model.Status, LastNote = model.LastNote, UpdatedBy = GlobalData.User.IDUser, Phone = model.Phone, SaleCode = model.SaleCode, AssignId = model.AssignId, Id = model.Id, GroupId = model.GroupId, DistrictId = model.DistrictId, ProvinceId = model.ProvinceId }; var result = await _rpCourierProfile.Update(model.Id, hoso); if (result) { if (!string.IsNullOrWhiteSpace(model.SaleCode)) { if (sale != null) { await _rpCourierProfile.InsertCourierAssignee(model.Id, sale.Id); } } _rpCourierProfile.InsertCourierAssignee(model.Id, model.AssignId); if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new GhichuModel { Noidung = model.LastNote, HosoId = model.Id, UserId = hoso.UpdatedBy, TypeId = (int)NoteType.HosoCourrier }; await _rpNote.AddNoteAsync(note); } } return(ToResponse(true)); }
public async Task <ActionResult> Create(HosoCorrierRequestModel model) { if (model == null) { return(ToResponse(false, "Dữ liệu không hợp lệ", 0)); } if (model.AssignId <= 0) { return(ToResponse(false, "Vui lòng chọn Courier", 0)); } var sale = await _rpEmployee.GetEmployeeByCode(model.SaleCode.ToString().Trim()); if (sale == null) { return(ToResponse(false, "Sale không tồn tại, vui lòng kiểm tra lại")); } var hoso = new HosoCourier { CustomerName = model.CustomerName, Cmnd = model.Cmnd, Status = (int)HosoCourierStatus.New, LastNote = model.LastNote, CreatedBy = GlobalData.User.IDUser, SaleCode = model.SaleCode, Phone = model.Phone, AssignId = model.AssignId, GroupId = model.GroupId, DistrictId = model.DistrictId, ProvinceId = model.ProvinceId }; var id = await _rpCourierProfile.Create(hoso); if (id > 0) { var tasks = new List <Task>(); var ids = new List <int>() { model.AssignId, GlobalData.User.IDUser, 1 }; //1 is Thainm if (!string.IsNullOrWhiteSpace(model.SaleCode)) { if (sale != null) { ids.Add(sale.Id); } } foreach (var assigneeId in ids) { tasks.Add(_rpCourierProfile.InsertCourierAssignee(id, assigneeId)); } await Task.WhenAll(tasks); if (!string.IsNullOrWhiteSpace(model.LastNote)) { var note = new GhichuModel { Noidung = model.LastNote, HosoId = id, UserId = hoso.CreatedBy, TypeId = (int)NoteType.HosoCourrier }; await _rpNote.AddNoteAsync(note); } return(ToResponse(true, "", id)); } return(ToResponse(false)); }
public async Task <JsonResult> CapNhat(int id, string hoten, string phone, string phone2, string ngayNhanDon, int hoSoCuaAi, string cmnd, int gioiTinh , int maKhuVuc, string diaChi, int sanPhamVay, string tenCuaHang, int baoHiem, int thoiHanVay, string soTienVay, int trangThai, int ketQua, string ghiChu, string birthDayStr, string cmndDayStr, int courier = 0, List <int> FileRequireIds = null) { try { if (hoten == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập họ tên")); } if (phone == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập số điện thoại")); } if (ngayNhanDon == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập ngày nhận đơn")); } if (cmnd == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập CMND")); } if (diaChi == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập địa chỉ")); } if (maKhuVuc == 0) { return(ToJsonResponse(false, "Vui lòng chọn quận/ huyện")); } if (sanPhamVay == 0) { return(ToJsonResponse(false, "Vui lòng chọn sản phẩm vay")); } if (soTienVay == string.Empty) { return(ToJsonResponse(false, "Vui lòng nhập số tiền vay")); } if (string.IsNullOrWhiteSpace(birthDayStr)) { return(ToJsonResponse(false, "Vui lòng nhập ngày sinh")); } if (string.IsNullOrWhiteSpace(cmndDayStr)) { return(ToJsonResponse(false, "Vui lòng nhập ngày cấp cmnd")); } //List<TaiLieuModel> lstTaiLieu = (List<TaiLieuModel>)Session["Duyet_LstFileHoSo"]; List <LoaiTaiLieuModel> lstLoaiTaiLieu = new LoaiTaiLieuBLL().LayDS(); lstLoaiTaiLieu.RemoveAll(x => x.BatBuoc == 0); if (lstLoaiTaiLieu != null) { var missingNames = BusinessExtension.GetFilesMissingV2(lstLoaiTaiLieu, FileRequireIds); if (!string.IsNullOrWhiteSpace(missingNames)) { return(ToJsonResponse(false, $"Vui lòng nhập: {missingNames}")); } } HoSoModel hs = new HoSoModel(); hs.ID = id; hs.TenKhachHang = hoten; hs.SDT = phone; hs.SDT2 = phone2; if (ngayNhanDon != string.Empty) { hs.NgayNhanDon = DateTimeFormat.ConvertddMMyyyyToDateTime(ngayNhanDon); } hs.HoSoCuaAi = hoSoCuaAi; hs.MaNguoiCapNhat = GlobalData.User.IDUser; hs.NgayCapNhat = DateTime.Now; hs.CMND = cmnd; hs.GioiTinh = gioiTinh; hs.MaKhuVuc = maKhuVuc; hs.DiaChi = diaChi; hs.CourierCode = courier; hs.SanPhamVay = sanPhamVay; hs.TenCuaHang = tenCuaHang; hs.CoBaoHiem = baoHiem; hs.HanVay = thoiHanVay; var dtBirthDayConvert = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(birthDayStr); if (!dtBirthDayConvert.Success) { return(ToJsonResponse(false, dtBirthDayConvert.Message)); } else { hs.BirthDay = dtBirthDayConvert.Value; } var dtCmnd = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(cmndDayStr); if (!dtCmnd.Success) { return(ToJsonResponse(false, dtCmnd.Message)); } else { hs.CmndDay = dtCmnd.Value; } if (soTienVay == string.Empty) { soTienVay = "0"; } hs.SoTienVay = Convert.ToDecimal(soTienVay); hs.MaTrangThai = trangThai; hs.MaKetQua = ketQua; int result = 0; if (hs.ID > 0) { var hosoOld = new HoSoBLL().LayChiTiet(id); if (!(hosoOld.MaTrangThai == trangThai && hosoOld.MaKetQua == ketQua)) { new HoSoXemBLL().Them(hosoOld.ID); } hs.DisbursementDate = hosoOld.DisbursementDate; if (hs.MaTrangThai == (int)TrangThaiHoSo.GiaiNgan) { hs.DisbursementDate = DateTime.Now; } bool isCheckMaSanPham = false; //// chỉnh sửa if (new HoSoBLL().CapNhatHoSo(hs, null, ref isCheckMaSanPham)) { result = 1; } else { if (isCheckMaSanPham) { return(ToJsonResponse(false, "Mã sản phẩm đã được sử dụng bởi 1 hồ sơ khác, vui lòng chọn mã sản phẩm khác")); } } } if (result > 0) { bool rs = new HoSoBLL().CapNhatTrangThaiHS(id, GlobalData.User.IDUser, DateTime.Now, trangThai, ketQua, ghiChu); if (rs) { GhichuModel ghichu = new GhichuModel { UserId = GlobalData.User.IDUser, HosoId = hs.ID, Noidung = ghiChu, CommentTime = DateTime.Now, TypeId = (int)NoteType.Hoso }; await _rpNote.AddNoteAsync(ghichu); return(ToJsonResponse(true, Resources.Global.Message_Succ, hs.ID)); } return(ToJsonResponse(false, "Không thành công, xin thử lại sau")); } return(ToJsonResponse(false, "Không thành công, xin thử lại sau")); } catch (Exception e) { return(ToJsonResponse(false, e.Message)); } }