protected virtual void ValidateStoreProperties(Store store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } var validator = new StoreValidator(); validator.ValidateAndThrow(store); }
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); } }
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 }); } }
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 }); } }
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 }); } }
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 }); } }
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); }
public BOStores(GDOCContext _db, List <Stores> _store) { db = _db; Stores = _store; StoreValidator = new StoreValidator(_db, _store); }
public BOStores(GDOCContext _db) { db = _db; StoreValidator = new StoreValidator(_db); }
public BOStores(GDOCContext _db, Stores _store) { db = _db; Store = _store; StoreValidator = new StoreValidator(_db, _store); }