public static AppLab_Parm AddNewParm(AppLab_Parm source) { var test = new Lab_Parms { Name = source.Name, Unit = source.Unit, NormarVal = source.NormarVal, Price = source.Price, Status = true, Id = source.Id }; using (var dbContext = new HMSEntities()) { var parm = dbContext.Lab_Parms.FirstOrDefault(p => p.Id == test.Id); if (parm != null) { parm.Name = test.Name; parm.Unit = test.Unit; parm.Price = test.Price; parm.NormarVal = test.NormarVal; } else { dbContext.Lab_Parms.Add(test); } dbContext.SaveChanges(); } return(test.Mapper()); }
public static AppLab_ParmDd MapperDd(this Lab_Parms source) { return(new AppLab_ParmDd { id = source.Id, Name = source.Name, Price = source.Price ?? 0, NorVal = source.NormarVal }); }
public static AppLab_Parm Mapper(this Lab_Parms source) { List <AppLab_mapping> mapping = null; if (source.Lab_Mapping != null && source.Lab_Mapping.Any()) { mapping = source.Lab_Mapping.Select(map => map.Mapper()).ToList(); } return(new AppLab_Parm { Id = source.Id, Name = source.Name, Status = source.Status, Price = source.Price ?? 0, NormarVal = source.NormarVal, Unit = source.Unit, Lab_Mappings = mapping }); }