Search code examples
c#if-statementusing-statement

using if statement under using case


this says need to return path but i cant reach if cases is there any way ? thanks

public IEnumerable<RequestCall> GetRequests(string erisim, string sube, string sicil)
{
    using (var redisclient = RedisManager.GetClient())
    {
        var redisUser = redisclient.As<RequestCall>();

        if (erisim == "A")
        {
            return redisUser.GetAll();// .Where(c=>c.Sube=="Y");
        }
        else if (erisim == "P")
        {
            return redisUser.GetAll().Where(c => c.Sube == sube);
        }
        else if (erisim == "C")
        {
            return redisUser.GetAll().Where(c => c.CagriAcan == sicil);
        }

    }
}

this says need to return path but i cant reach if cases is there any way ? thanks


Solution

  • You could try this one:

    if (erisim == "A")
    {
        return redisUser.GetAll();// .Where(c=>c.Sube=="Y");
    }
    else if (erisim == "P")
    {
        return redisUser.GetAll().Where(c => c.Sube == sube);
    }
    else if (erisim == "C")
    {
        return redisUser.GetAll().Where(c => c.CagriAcan == sicil);
    }
    else
    {
        return Enumerable.Empty<RequestCall>();
    }