public int Post(ProfileAdd model) { int id = 0; cmd.CommandText = "Company_Insert"; SqlParameter param = new SqlParameter(); param.ParameterName = "@Id"; param.SqlDbType = System.Data.SqlDbType.Int; param.Direction = System.Data.ParameterDirection.Output; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@UserId", model.UserId); cmd.Parameters.AddWithValue("@CompName", model.CompName); cmd.Parameters.AddWithValue("@FName", model.FName); cmd.Parameters.AddWithValue("@LName", model.LName); cmd.Parameters.AddWithValue("@Street", model.Street); cmd.Parameters.AddWithValue("@City", model.City); cmd.Parameters.AddWithValue("@State", model.State); cmd.Parameters.AddWithValue("@Zip", model.Zip); cmd.Parameters.AddWithValue("@Email", model.Email); cmd.Parameters.AddWithValue("@Phone", model.Phone); cmd.Parameters.AddWithValue("@ModifiedBy", model.ModifiedBy); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); id = (int)cmd.Parameters["@Id"].Value; return(id); }
public async Task <int> CreateAsync(ProfileAdd model) { if (ValidateProfile(model) == false) { return(0); } if (model.SaleId <= 0) { model.SaleId = _process.User.Id; } model.Status = (int)ProfileStatus.Draft; var sqlmodel = _mapper.Map <ProfileAddSql>(model); var result = await _rpProfile.CreateAsync(sqlmodel, _process.User.Id); if (result.data > 0 && !string.IsNullOrWhiteSpace(model.Comment)) { var bzNot = _svProvider.GetService <INoteBusiness>(); await bzNot.AddNoteAsync(new Entities.Note.NoteAddRequest { Content = model.Comment, ProfileId = result.data, ProfileTypeId = (int)NoteType.Common }); } return(ToResponse(result)); }
public async Task <bool> UpdateProfile(ProfileAdd model) { if (!ValidateProfile(model)) { return(false); } var profile = await _rpProfile.GetByIdAsync(model.Id); if (!profile.success) { return(ToResponse(false, Errors.profile_could_not_found_in_portal)); } if (model.SaleId <= 0) { model.SaleId = _process.User.Id; } if (_process.User.isSale) { await _rpProfile.UpdateStatusAsync(model.Id, (int)ProfileStatus.New, _process.User.Id); return(true); } if (_process.User.isRsmAsmSS) { if (model.Status == (int)ProfileStatus.Compared || model.Status == (int)ProfileStatus.Additional || model.Status == (int)ProfileStatus.Draft || model.Status == (int)ProfileStatus.New) { if (model.Status == (int)ProfileStatus.Draft) { model.Status = (int)ProfileStatus.New; } await _rpProfile.UpdateStatusAsync(model.Id, model.Status, _process.User.Id); return(true); } else { return(ToResponse(false, "Bạn chỉ được cập nhật trạng thái đã đối chiếu hoặc bổ sung hồ sơ")); } } model.Status = model.Status == (int)ProfileStatus.Draft ? (int)ProfileStatus.New : model.Status; var sqlmodel = _mapper.Map <ProfileAddSql>(model); var result = await _rpProfile.UpdateAsync(sqlmodel, model.Id, _process.User.Id); if (result.data == true) { await _rpProfileNoti.CreateAsync(model.Id); } return(ToResponse <bool>(result.data, result.error)); }
public async Task <IActionResult> Post([FromBody] ProfileAdd model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = await GetCurrentUser(); model.UserId = user.Id; DataResponse <int> resp = new DataResponse <int>(); resp.Data = _svc.Post(model); return(Ok(resp)); } catch (Exception ex) { return(StatusCode(404, ex)); } }
public async Task <IActionResult> UpdateAsync([FromBody] ProfileAdd model) { var result = await _bizProfile.UpdateProfile(model); return(ToResponse(result)); }
private void ProfileAddButton_Click(object sender, ProfileAddEventArgs e) => ProfileAdd?.Invoke(this, e);
protected bool ValidateProfile(ProfileAdd model) { if (model == null) { AddError(Errors.invalid_data); return(false); } if (!string.IsNullOrWhiteSpace(model.Comment) && model.Comment.Length > 200) { AddError(Errors.note_length_cannot_more_than_200); return(false); } if (model.PartnerId <= 0) { AddError(Errors.missing_partner); return(false); } if (string.IsNullOrWhiteSpace(model.CustomerName)) { AddError(Errors.customername_must_not_be_empty); return(false); } if (model.ProductId <= 0) { AddError(Errors.missing_product); return(false); } if (string.IsNullOrWhiteSpace(model.Phone)) { AddError(Errors.missing_phone); return(false); } if (model.ReceiveDate == null) { AddError(Errors.missing_ngaynhandon); return(false); } if (string.IsNullOrWhiteSpace(model.Cmnd)) { AddError(Errors.missing_cmnd); return(false); } if (model.DistrictId <= 0) { AddError(Errors.missing_district); return(false); } if (string.IsNullOrWhiteSpace(model.Address)) { AddError(Errors.missing_diachi); return(false); } if (model.LoanAmount <= 0) { AddError(Errors.missing_money); return(false); } if (model.BirthDay == null) { AddError(Errors.missing_birthday); return(false); } if (model.CmndDay == null) { AddError(Errors.missing_cmnd_day); return(false); } return(true); }