示例#1
0
        public async Task <int> CreateAsync(CompanyAddModel model)
        {
            if (model == null)
            {
                return(ToResponse(0, Errors.invalid_data));
            }
            var company  = _mapper.Map <CompanySql>(model);
            var response = await _rpCompany.CreateAsync(company, _process.User.Id);

            if (response.success)
            {
                if (!string.IsNullOrWhiteSpace(model.LastNote))
                {
                    var note = new NoteAddModel
                    {
                        Content       = model.LastNote,
                        ProfileId     = response.data,
                        ProfileTypeId = (int)NoteType.Company,
                        UserId        = _process.User.Id
                    };
                    await _rpNote.AddNoteAsync(note);
                }
            }
            return(ToResponse(response));
        }
示例#2
0
        public async Task <int> CreateAsync(CourierAddModel model)
        {
            var profile = _mapper.Map <CourierSql>(model);

            profile.CreatedBy = _process.User.Id;
            profile.Status    = (int)ProfileStatus.New;
            var response = await _rpCourier.CreateAsync(profile);

            if (!response.success)
            {
                return(ToResponse(response));
            }
            var sale = await _rpEmployee.GetEmployeeByCodeAsync(model.SaleCode.ToString().Trim(), _process.User.Id);

            if (sale == null)
            {
                return(ToResponse(0, "Sale không tồn tại, vui lòng kiểm tra lại"));
            }
            if (!string.IsNullOrWhiteSpace(model.LastNote))
            {
                var note = new NoteAddModel
                {
                    Content       = model.LastNote,
                    ProfileId     = response.data,
                    UserId        = _process.User.Id,
                    ProfileTypeId = (int)NoteType.Courier
                };
                await _rpNote.AddNoteAsync(note);
            }
            return(ToResponse(response));
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 public async Task AddNoteAsync(NoteAddModel 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.Content,
             hosoId      = model.ProfileId,
             commentTime = DateTime.Now,
             typeId      = model.ProfileTypeId
         }, commandType : CommandType.Text);
     }
 }