/// <summary> /// /// </summary> /// <param name="tableIds"></param> /// <param name="status"></param> /// <returns></returns> public bool UpdateTablesStatus(List <int> tableIds, CythStatus status) { using (var db = new SqlSugarClient(Connection)) { try { db.BeginTran(); var tableList = db.Queryable <R_Table>().Where(x => tableIds.Contains(x.Id)).ToList(); if (tableList == null || tableList.Count == 0) { throw new Exception("指定餐台不存在,不能执行空置清理操作!"); } StringBuilder errMsg = new StringBuilder(); foreach (var item in tableList) { if (item.CythStatus != CythStatus.清理) { errMsg.AppendLine(string.Format( "当前餐台({0})状态为:(1),不能执行空置清理操作!", item.Name, Enum.GetName(typeof(CythStatus), item.CythStatus))); } item.CythStatus = status; } if (errMsg != null && errMsg.Length > 0) { throw new Exception(errMsg.ToString()); } var result = db.UpdateRange(tableList); db.CommitTran(); return(result.Any(x => !x) ? false : true); } catch (Exception e) { db.RollbackTran(); throw e; } } }
public List <R_Table> GetTables(int[] restraurantIds, int?areaId, CythStatus statusType, bool inCludVirtual = true) { using (var db = new SqlSugarClient(Connection)) { var list = db.Queryable <R_Table>() .Where(x => restraurantIds.Contains(x.R_Restaurant_Id) && x.IsDelete == false); if (areaId.HasValue && areaId.Value > 0) { list = list.Where(x => x.R_Area_Id == areaId.Value); } if ((int)statusType > 0) { list = list.Where(x => x.CythStatus == statusType); } if (!inCludVirtual) { list = list.Where(p => p.IsVirtual == false); } return(list.ToList()); } }