แก้ api ลา

This commit is contained in:
kittapath 2024-11-18 18:43:46 +07:00
parent d08b4ca723
commit 4822110533
20 changed files with 20695 additions and 2783 deletions

View file

@ -57,87 +57,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
else
{
// var request = _context.InsigniaRequestProfiles
// .Include(x => x.Request)
// .ThenInclude(x => x.Period)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Insignias)
// .ThenInclude(x => x.Insignia)
// .ThenInclude(x => x.InsigniaType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
// .Where(x => x.Request.Period.Id == result.PeriodId)
// .Where(x => x.Request.RequestStatus == "st5p")
// .Where(x => x.IsApprove)
// .Select(p => new
// {
// Profile = p.Profile.Id,
// Name = $"{p.Profile.Prefix} {p.Profile.FirstName} {p.Profile.LastName}",
// Insignia = p.RequestInsignia,
// Type = p.RequestInsignia.InsigniaType,
// IsApprove = p.IsApprove,
// InsigniaId = p.RequestInsignia.Id,
// Year = p.Request.Period.Year,
// Special = p.Special,
// LastInsignia = p.Profile.Insignias.AsQueryable()
// .Include(x => x.Insignia)
// .Where(x => x.Insignia.Id == p.RequestInsignia.Id)
// .Where(x => x.Year == p.Request.Period.Year)
// .FirstOrDefault()
// })
// .ToList()
// .Select(r => new InsigniaReceiveResponse
// {
// Profile = r.Profile,
// Name = r.Name,
// Insignia = r.Insignia.Name,
// TypeId = r.Type == null ? null : r.Type.Id,
// TypeName = r.Type == null ? "" : r.Type.Description,
// IsApprove = r.IsApprove,
// InsigniaId = r.InsigniaId,
// InsigniaPage = r.LastInsignia == null ? "" : r.LastInsignia.Page,
// InsigniaNo = r.LastInsignia == null ? "" : r.LastInsignia.No,
// InsigniaIssue = r.LastInsignia == null ? "" : r.LastInsignia.Issue,
// InsigniaVolumeno = r.LastInsignia == null ? "" : r.LastInsignia.VolumeNo,
// InsigniaVolume = r.LastInsignia == null ? "" : r.LastInsignia.Volume,
// InsigniaSection = r.LastInsignia == null ? "" : r.LastInsignia.Section,
// InsigniaDatereceive = r.LastInsignia == null ? null : r.LastInsignia.DateReceive,
// InsigniaDateannounce = r.LastInsignia == null ? null : r.LastInsignia.DateAnnounce,
// Special = r.Special
// })
// .ToList()
// .GroupBy(r => new { r.TypeId, r.TypeName })
// .Select(r => new
// {
// TypeId = r.Key.TypeId,
// InsigniaIssue = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaIssue : "",
// InsigniaVolumeno = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaVolumeno : null,
// InsigniaVolume = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaVolume : "",
// InsigniaSection = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaSection : "",
// InsigniaDatereceive = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaDatereceive : null,
// InsigniaDateannounce = r.Where(r => r.InsigniaIssue != "").FirstOrDefault() != null ? r.Where(r => r.InsigniaIssue != "").FirstOrDefault().InsigniaDateannounce : null,
// TypeName = r.Key.TypeName,
// Profile = r.Select(r => new
// {
// Profile = r.Profile,
// Name = r.Name,
// Insignia = r.Insignia,
// InsigniaId = r.InsigniaId,
// InsigniaPage = r.InsigniaPage,
// InsigniaNo = r.InsigniaNo,
// //Special = bool.Parse(r.Special)
// }).ToList(),
// Docs = new List<dynamic>()
// });
return Success();
// return Success(request);
}
}
@ -179,68 +99,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
}, AccessToken);
}
// foreach (var i in items.Profile)
// {
// var profile = _context.Profiles.AsQueryable()
// .Include(x => x.Insignias)
// .ThenInclude(x => x.Insignia)
// .Where(x => x.Id == i.FkProfileId)
// .FirstOrDefault();
// if (profile != null)
// {
// var kp7 = profile.Insignias.AsQueryable()
// .Where(x => x.Insignia.Id == i.Kp7InsigniaId)
// .FirstOrDefault();
// if (kp7 != null)
// {
// // exit item update to database
// kp7.DateReceive = items.InsigniaDatereceive.Value;
// kp7.Level = items.InsigniaLevel;
// kp7.Issue = items.InsigniaIssue;
// kp7.VolumeNo = items.InsigniaVolumeno.Value.ToString();
// kp7.Volume = items.InsigniaVolume;
// kp7.Section = items.InsigniaSection;
// kp7.DateAnnounce = items.InsigniaDateannounce.Value;
// kp7.Page = i.InsigniaPage;
// kp7.No = i.InsigniaNo;
// }
// else
// {
// // insert new item to kp7
// var insignia_item = _context.Insignias.FirstOrDefault(x => x.Id == i.Kp7InsigniaId);
// var result = _repository.GetInsigniaRequest(type, items.OCId);
// var period = _context.InsigniaPeriods.FirstOrDefault(x => x.Id == result.PeriodId);
// kp7 = new Models.HR.ProfileInsignia
// {
// Order = profile.Insignias.ToList().Count + 1,
// Year = period.Year,
// Insignia = insignia_item,
// DateReceive = items.InsigniaDatereceive.Value,
// DateStamp = DateTime.Now,
// Level = items.InsigniaLevel,
// Issue = items.InsigniaIssue,
// VolumeNo = items.InsigniaVolumeno.Value.ToString(),
// Volume = items.InsigniaVolume,
// Section = items.InsigniaSection,
// DateAnnounce = items.InsigniaDateannounce.Value,
// Page = i.InsigniaPage,
// No = i.InsigniaNo,
// };
// profile.Insignias.Add(kp7);
// }
// }
// else
// return NotFound("Profile not found!!!");
// }
}
//_context.SaveChanges();
return Success();
}