private bool IsCustomerQueExist(Que que) { DateTime from = que.FromDate.AddMilliseconds(10); DateTime to = que.ToDate.AddMilliseconds(-10); string sql = @"SELECT count(1) FROM Que WHERE [UserId] = @UserId And EmployeeId = @EmployeeId And (([FromDate] between @FromDate And @ToDate) Or ([ToDate] between @FromDate And @ToDate ))" ; DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); return(db.IsExist(sql, new { UserId = que.UserId, FromDate = from, ToDate = to, EmployeeId = que.EmployeeId }, 1)); //IEnumerable<int> data = // db.QueryData<int>(sql, 1, new { UserId = que.UserId, FromDate = que.FromDate, ToDate = que.ToDate, EmployeeId = que.EmployeeId }); //bool isExist = false; //foreach(int i in data) //{ // isExist = true; //} //return isExist; }
private bool IsCustomerExist(string guid) { string sql = "SELECT count(1) FROM Customer WHERE [Active] = @guid;"; DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); return(db.IsExist(sql, new { guid = guid }, 1)); }
private void AddCusomersToUsers(int userId, int customerId) { string sql = "Select count(1) from UsersToCusomers Where [UserId]=@UserId And [CustomerId]=@CustomerId;"; DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); bool isExist = db.IsExist(sql, new { UserId = userId, CustomerId = customerId }, 1); if (!isExist) { string sqlUserCustomerInsert = @"INSERT INTO UsersToCusomers ([UserId],[CustomerId]) Values (@UserId,@CustomerId);"; var Rows = db.Execute(sqlUserCustomerInsert, 1, new { UserId = userId, CustomerId = customerId }); } }
private bool isCustomerAllowDeleteHisQue(Que que) { var sql = @"SELECT count(1) FROM Que A INNER JOIN Customer B on A.CustomerId = B.Id WHERE A.UserId = @UserId And A.FromDate=@FromDate And A.ToDate=@ToDate And A.QueType = @QueType And A.CustomerId = @CustomerId And A.EmployeeId=@EmployeeId And B.Active=@guid"; //string sql = "SELECT count(1) FROM Customer WHERE [guid] = @guid;"; DataBaseRetriever db = new DataBaseRetriever(ConfigManager.ConnectionString); return(db.IsExist(sql, que, 1)); }