public bool EditByTypeId(List <SystemFluidConfiguration> recordList, short typeId) { try { using (WanTaiEntities entities = new WanTaiEntities()) { var records = entities.SystemFluidConfigurations.Where(p => p.ItemType == typeId); foreach (SystemFluidConfiguration record in records) { entities.DeleteObject(record); } foreach (SystemFluidConfiguration record in recordList) { record.ItemID = WanTaiObjectService.NewSequentialGuid(); entities.AddToSystemFluidConfigurations(record); } entities.SaveChanges(); return(true); } } catch (Exception e) { string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "." + MethodBase.GetCurrentMethod(), SessionInfo.ExperimentID); return(false); } }
public bool Delete(Guid itemId) { try { using (WanTaiEntities entities = new WanTaiEntities()) { var record = entities.ReagentAndSuppliesConfigurations.Where(p => p.ItemID == itemId).FirstOrDefault(); entities.DeleteObject(record); entities.SaveChanges(); return(true); } } catch (Exception e) { string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->Delete", SessionInfo.ExperimentID); return(false); } }
public bool Create(List <RotationInfo> rotationInfoList) { try { using (WanTaiEntities entities = new WanTaiEntities()) { var oldRotations = entities.RotationInfoes.Where(c => c.ExperimentID == SessionInfo.ExperimentID); if (oldRotations.Count() > 0) { foreach (RotationInfo old in oldRotations) { entities.DeleteObject(old); } } foreach (RotationInfo rotationInfo in rotationInfoList) { entities.AddToRotationInfoes(rotationInfo); if (rotationInfo.TubesBatchID != null) { var plates = entities.Plates.Where(P => P.TubesBatchID == rotationInfo.TubesBatchID); foreach (Plate plate in plates) { plate.RotationID = rotationInfo.RotationID; } } } entities.SaveChanges(); } return(true); } catch (Exception e) { string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "Create()", SessionInfo.ExperimentID); return(false); } }