public static AppLab_Test AddMixReport(CreateMixReportModel source) { var test = new Lab_Tests { Name = source.Name, Fee = source.Fee, Interval = 30, Status = true, }; using (var dbContext = new HMSEntities()) { test.CreationDate = DateTime.Now; dbContext.Lab_Tests.Add(test); dbContext.SaveChanges(); foreach (var obj in source.ParmIds) { var testMapping = new Lab_Mapping { TestId = test.Id, ParmId = obj, CreationDate = DateTime.Now }; dbContext.Lab_Mapping.Add(testMapping); } dbContext.SaveChanges(); return(test.Mapper()); } }
public static AppLab_mapping Mapper(this Lab_Mapping source) { return(new AppLab_mapping { Id = source.Id, CreationDate = source.CreationDate.ToShortDateString(), // Lab_Parm = source.Lab_Parms.Mapper(), // Lab_Test = source.Lab_Tests.Mapper(), ParmId = source.ParmId, TestId = source.TestId, TestName = source.Lab_Tests?.Name, ParmName = source.Lab_Parms?.Name }); }
public static void AddNewMapping(List <AppLab_mapping> source) { using (var dbContext = new HMSEntities()) { foreach (var obj in source) { var test = new Lab_Mapping { TestId = obj.TestId, ParmId = obj.ParmId, CreationDate = DateTime.Now }; dbContext.Lab_Mapping.Add(test); } dbContext.SaveChanges(); } }