public HttpResponseMessage PutStores(StoresRequest oModel) { try { using (BackNetEntity db = new BackNetEntity()) { stores oStore = db.stores.Find(oModel.id); if (oStore == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "La Store con el Id " + oModel.id.ToString() + " no pudo actualizarse")); } else { oStore.name = oModel.name; oStore.address = oModel.address; db.Entry(oStore).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public virtual async Task <IHttpActionResult> GetStoresByLocation(StoresRequest request) { var vm = await StoreViewService.GetAllStoresViewModelAsync(new GetStoresParam { BaseUrl = RequestUtils.GetBaseUrl(Request).ToString(), CultureInfo = ComposerContext.CultureInfo, Scope = ComposerContext.Scope, SearchPoint = request.SearchPoint }); return(Ok(vm)); }
public virtual async Task <IHttpActionResult> GetStores(StoresRequest request) { var vm = await StoreLocatorViewService.GetStoreLocatorViewModelAsync(new GetStoreLocatorViewModelParam { Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, BaseUrl = RequestUtils.GetBaseUrl(Request).ToString(), PageNumber = request.Page, PageSize = request.PageSize > 0 ? request.PageSize : StoreConfiguration.StoreLocatorMaxItemsPerPage, MapBounds = request.MapBounds, SearchPoint = request.SearchPoint, IncludeMarkers = false }).ConfigureAwait(false); return(Ok(vm)); }
public HttpResponseMessage AddStores([FromBody] StoresRequest store) { try { using (BackNetEntity db = new BackNetEntity()) { var oStores = new Models.stores(); oStores.name = store.name; oStores.address = store.address; db.stores.Add(oStores); db.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, store); message.Headers.Location = new Uri(Request.RequestUri + store.id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (Editar == true) { DialogResult result = MessageBox.Show("¿Seguro que desea Modificar el regustro seleccionado?", "Atención!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { //IMPLEMENTACION DEL METODO PUT string urlEdit = url + "services/updStores"; try { StoresRequest oStores = new StoresRequest(); oStores.id = int.Parse(txtId.Text); oStores.name = txtName.Text; oStores.address = txtAddress.Text; string resultado = Send <StoresRequest>(urlEdit, oStores, "PUT"); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } listStores(); Editar = false; btnAdd.Enabled = true; btnAdd.Show(); btnDelete.Enabled = false; btnGuardar.Hide(); btnRefresh.Enabled = true; btnUpdate.Enabled = true; btnSearch.Enabled = true; txtAddress.Enabled = true; txtName.Enabled = true; iniciarControles(); reiniciarControles(); } else if (Eliminar == true) { DialogResult result = MessageBox.Show("¿Seguro que desea eliminar el registro seleccionado?", "Atención!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { //IMPLEMENTACION DEL METODO DELETE string urlDelete = url + "services/delStores?id=" + txtId.Text; try { StoresRequest oStores = new StoresRequest(); oStores.id = int.Parse(txtId.Text); string resultado = Send <StoresRequest>(urlDelete, oStores, "DELETE"); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } listStores(); Eliminar = false; btnAdd.Enabled = true; btnAdd.Show(); btnDelete.Enabled = true; btnGuardar.Hide(); btnRefresh.Enabled = true; btnUpdate.Enabled = false; btnSearch.Enabled = true; txtAddress.Enabled = false; txtName.Enabled = false; iniciarControles(); reiniciarControles(); } else { if (txtName.Text == "" || txtAddress.Text == "") { epValidation.SetError(txtName, "Los campos no debe estar vacio"); epValidation.SetError(txtAddress, "Los campos no debe estar vacio"); } else { borrarMensajeError(); //IMPLEMENTACION DEL METODO POST string urlAdd = url + "services/addStores"; try { StoresRequest oStores = new StoresRequest(); oStores.name = txtName.Text; oStores.address = txtAddress.Text; string resultado = Send <StoresRequest>(urlAdd, oStores, "POST"); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } } }