Ejemplo n.º 1
0
        public async Task <PetitionResponse> GetByID(int companyid, int storeid)
        {
            Stores stores = new Stores();

            try
            {
                if (!StoreValidator.canGetResult())
                {
                    return(new PetitionResponse
                    {
                        success = false,
                        message = StoreValidator.Resultado,
                        module = "Stores",
                        URL = "pos/Stores/GetByCompany",
                        result = stores
                    });
                }


                stores = await db.Stores.Where(x => x.CompanyID == companyid && x.StoreId == storeid && x.Name == "Juan").FirstOrDefaultAsync();

                stores.NombreAMostrar = stores.Name + "- " + stores.StoreCode;

                return(new PetitionResponse
                {
                    success = true,
                    message = "Tiendas consultadas con éxito.",
                    module = "Stores",
                    URL = "pos/Stores/GetByCompany",
                    result = stores
                });
            }
            catch (Exception ex)
            {
                return(new PetitionResponse
                {
                    success = false,
                    message = "No es posible consultar las tiendas de la compañia: " + ex.Message,
                    module = "Stores",
                    URL = "pos/Stores/GetByCompany",
                    result = stores
                });
            }
        }
Ejemplo n.º 2
0
        public async Task <PetitionResponse> GetByCompany(int companyid)
        {
            List <Stores> listStores = new List <Stores>();

            try
            {
                if (!StoreValidator.canGetResult())
                {
                    return(new PetitionResponse
                    {
                        success = false,
                        message = StoreValidator.Resultado,
                        module = "Stores",
                        URL = "pos/Stores/GetByCompany",
                        result = listStores
                    });
                }


                listStores = await db.Stores.Where(x => x.CompanyID == companyid).ToListAsync();

                return(new PetitionResponse
                {
                    success = true,
                    message = "Tiendas consultadas con éxito.",
                    module = "Stores",
                    URL = "pos/Stores/GetByCompany",
                    result = listStores
                });
            }
            catch (Exception ex)
            {
                return(new PetitionResponse
                {
                    success = false,
                    message = "No es posible consultar las tiendas de la compañia: " + ex.Message,
                    module = "Stores",
                    URL = "pos/Stores/GetByCompany",
                    result = listStores
                });
            }
        }