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 }); } }