private bool IsWorkflowOrderItemDuplicate(string name, int workFlowOrderId, int order, int callType, ref SettingRegRespObj response) { try { var sql1 = $"Select coalesce(Count(\"WorkflowOrderItemId\"), 0) FROM \"GPlus\".\"WorkflowOrderItem\" WHERE lower(\"Name\") = lower('{name.Replace("'", "''")}') AND \"WorkflowOrderId\" = {workFlowOrderId} AND \"Order\" = {order}"; var check = _repository.RepositoryContext().Database.SqlQuery <long>(sql1).ToList(); if (check.IsNullOrEmpty()) { response.Status.Message.FriendlyMessage = "Unable to complete your request due to validation error. Please try again later"; response.Status.Message.TechnicalMessage = "Unable to check for duplicate"; return(true); } if (check.Count != 1) { response.Status.Message.FriendlyMessage = "Unable to complete your request due to validation error. Please try again later"; response.Status.Message.TechnicalMessage = "Unable to check for duplicate"; return(true); } if (check[0] < 1) { return(false); } if (check[0] > 0) { if (callType != 2 || check[0] > 1) { response.Status.Message.FriendlyMessage = "Duplicate Error!WorkflowOrderItem Name already exist"; response.Status.Message.TechnicalMessage = "Duplicate Error! WorkflowOrderItem Name already exist"; return(true); } return(false); } return(false); } catch (Exception ex) { response.Status.Message.FriendlyMessage = "Unable to complete your request due to validation error. Please try again later"; response.Status.Message.TechnicalMessage = "Duplicate Check Error: " + ex.Message; ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(true); } }
private static void Purge() { try { var sql1 = "Select coalesce(Count(\"SerialNumberKeeperId\"), 0) FROM \"VSalesKiosk\".\"SerialNumberKeeper\";"; var check = _repository.RepositoryContext().Database.SqlQuery <long>(sql1).ToList(); if (check.IsNullOrEmpty()) { return; } if (check[0] > 10000) { sql1 = "Delete FROM \"VSalesKiosk\".\"SerialNumberKeeper\";"; _repository.RepositoryContext().Database.ExecuteSqlCommand(sql1); } } catch (Exception) { //ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.GetBaseException().Message); } }