diff --git a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs index 98c0f652..beea1128 100644 --- a/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia/Controllers/InsigniaRequestController.cs @@ -2293,24 +2293,71 @@ namespace BMA.EHR.Insignia.Service.Controllers if (profile.Status != "DONE") { profile.Status = "DONE"; - var profileInsignia = new PostProfileInsigniaDto + + // check profile.ProfileType ก่อนส่งไประบบทะเบียนประวัติ + if (profile.ProfileType == "OFFICER") { - profileId = profile.ProfileId.Value, - year = insigniaNote.Year, - no = profile.No, - volumeNo = profile.VolumeNo, - section = profile.Section, - page = profile.Page, - receiveDate = profile.DateReceive.Value, - dateAnnounce = profile.Date.Value, - insigniaId = profile.RequestInsignia.Id, - issue = "", - note = "", - refCommandDate = null, - refCommandNo = "", - volume = "", - }; - await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken); + var profileInsigniaBody = new PostProfileInsigniaDto + { + profileId = profile!.ProfileId!.Value, + year = insigniaNote.Year, + no = profile!.No ?? "", + volumeNo = profile!.VolumeNo ?? "", + section = profile!.Section ?? "", + page = profile!.Page ?? "", + receiveDate = profile.DateReceive!.Value, + dateAnnounce = profile.Date!.Value, + insigniaId = profile.RequestInsignia!.Id, + issue = "", + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + + }; + await _userProfileRepository.PostProfileInsigniaAsync(profileInsigniaBody, AccessToken); + } + else + { + var profileInsigniaBody = new PostProfileEmpInsigniaDto + { + profileEmployeeId = profile!.ProfileId!.Value, + year = insigniaNote.Year, + no = profile!.No ?? "", + volumeNo = profile!.VolumeNo ?? "", + section = profile!.Section ?? "", + page = profile!.Page ?? "", + receiveDate = profile.DateReceive!.Value, + dateAnnounce = profile.Date!.Value, + insigniaId = profile.RequestInsignia!.Id, + issue = "", + note = "", + refCommandDate = null, + refCommandNo = "", + volume = "", + + }; + await _userProfileRepository.PostProfileEmpInsigniaAsync(profileInsigniaBody, AccessToken); + } + + //var profileInsignia = new PostProfileInsigniaDto + //{ + // profileId = profile.ProfileId.Value, + // year = insigniaNote.Year, + // no = profile.No, + // volumeNo = profile.VolumeNo, + // section = profile.Section, + // page = profile.Page, + // receiveDate = profile.DateReceive.Value, + // dateAnnounce = profile.Date.Value, + // insigniaId = profile.RequestInsignia.Id, + // issue = "", + // note = "", + // refCommandDate = null, + // refCommandNo = "", + // volume = "", + //}; + //await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken); } } await _context.SaveChangesAsync();