protected virtual void ValidateStoreProperties(Store store)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }

            var validator = new StoreValidator();

            validator.ValidateAndThrow(store);
        }
Пример #2
0
        private void ValidateStoresProperties(IEnumerable <Store> stores)
        {
            if (stores == null)
            {
                throw new ArgumentNullException(nameof(stores));
            }

            var validator = new StoreValidator();

            foreach (var store in stores)
            {
                validator.ValidateAndThrow(store);
            }
        }
Пример #3
0
        public async Task <PetitionResponse> Add()
        {
            try
            {
                if (!StoreValidator.canSave())
                {
                    return(new PetitionResponse
                    {
                        success = false,
                        message = StoreValidator.Resultado,
                        module = "Stores",
                        URL = "pos/Stores/Add",
                        result = Store
                    });
                }

                db.Stores.Add(Store);
                if (await db.SaveChangesAsync() <= 0)
                {
                    return(new PetitionResponse
                    {
                        success = false,
                        message = "No es posible guardar la tienda de la compañia",
                        module = "Stores",
                        URL = "pos/Stores/Add",
                        result = Store
                    });
                }
                return(new PetitionResponse
                {
                    success = true,
                    message = "Tienda creada con exito!",
                    module = "Stores",
                    URL = "pos/Stores/Add",
                    result = Store
                });
            }
            catch (Exception ex)
            {
                return(new PetitionResponse
                {
                    success = false,
                    message = "No es posible guardar la tienda de la compañia: " + ex.Message,
                    module = "Stores",
                    URL = "pos/Stores/Add",
                    result = null
                });
            }
        }
Пример #4
0
 public async Task <PetitionResponse> Update()
 {
     try
     {
         if (!StoreValidator.canSave())
         {
             return(new PetitionResponse
             {
                 success = false,
                 message = StoreValidator.Resultado,
                 module = "Stores",
                 URL = "pos/Stores/Update",
                 result = Store
             });
         }
         db.Entry(this.Store).State = EntityState.Modified;
         if (await db.SaveChangesAsync() <= 0)
         {
             return(new PetitionResponse
             {
                 success = false,
                 message = "No es posible actualizar la tienda de la compañia",
                 module = "Stores",
                 URL = "pos/Stores/Update",
                 result = Store
             });
         }
         return(new PetitionResponse
         {
             success = true,
             message = "Tienda actualizada con exito!",
             module = "Stores",
             URL = "pos/Stores/Update",
             result = Store
         });
     }
     catch (Exception ex)
     {
         return(new PetitionResponse
         {
             success = false,
             message = "No es posible actualizar la tienda de la compañia: " + ex.Message,
             module = "Stores",
             URL = "pos/Stores/Update",
             result = null
         });
     }
 }
Пример #5
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
                });
            }
        }
Пример #6
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
                });
            }
        }
Пример #7
0
        private bool ValidateStoreInformation()
        {
            // Validate my data and save in the results variable
            StoreValidator storeValidator = new StoreValidator();
            var            results        = storeValidator.Validate(this.store);

            // Check if the validator found any validation errors.
            if (results.IsValid == false)
            {
                foreach (ValidationFailure failure in results.Errors)
                {
                    MessageBox.Show($"{ failure.ErrorMessage }", "Store Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public void SetUp()
        {
            _internalCommandService.ResetCalls();

            _storeValidator = new StoreValidator(_internalCommandService.Object);
        }
Пример #9
0
 public BOStores(GDOCContext _db, List <Stores> _store)
 {
     db             = _db;
     Stores         = _store;
     StoreValidator = new StoreValidator(_db, _store);
 }
Пример #10
0
 public BOStores(GDOCContext _db)
 {
     db             = _db;
     StoreValidator = new StoreValidator(_db);
 }
Пример #11
0
 public BOStores(GDOCContext _db, Stores _store)
 {
     db             = _db;
     Store          = _store;
     StoreValidator = new StoreValidator(_db, _store);
 }