private void saveChangesBtn_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { LocalEventsSeminarski_API.Models.Lokacija lokacija = new LocalEventsSeminarski_API.Models.Lokacija(); lokacija.LokacijaID = lokacijaID; lokacija.Naziv = nazivInput.Text; lokacija.Adresa = adresaInput.Text; lokacija.Kapacitet = Convert.ToInt32(kapacitetInput.Value); lokacija.Opis = opisInput.Text; lokacija.GradID = Convert.ToInt32(gradSelect.SelectedValue); lokacija.LokacijaTipID = Convert.ToInt32(tipSelect.SelectedValue); //MessageBox.Show(lokacijaID.ToString() + " " + lokacija.Naziv + " " + lokacija.Adresa + lokacija.Kapacitet.ToString()); HttpResponseMessage saveChangesResponse = lokacijaService.PutResponse(lokacija.LokacijaID, lokacija); if (saveChangesResponse.IsSuccessStatusCode) { MessageBox.Show("Saved Changes!"); Close(); } else { MessageBox.Show("error"); } } }
private void slikaDodajBtn_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); slikaInput.Text = openFileDialog1.FileName; novaLokacija.Slika = File.ReadAllBytes(slikaInput.Text); Image orgImage = Image.FromFile(slikaInput.Text); int resizedImgWidth = Convert.ToInt32(ConfigurationManager.AppSettings["resizedImgWidth"]); int resizedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["resizedImgHeight"]); int croppedImgWidth = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgWidth"]); int croppedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgHeight"]); if (orgImage.Width > resizedImgWidth) { Image resizedImg = UIHelper.ResizeImage(orgImage, new Size(resizedImgWidth, resizedImgHeight)); if (resizedImg.Width > croppedImgWidth && resizedImg.Height > croppedImgHeight) { int croppedXPosition = (resizedImg.Width - croppedImgWidth) / 2; int croppedYPosition = (resizedImg.Height - croppedImgHeight) / 2; Image croppedImg = UIHelper.CropImage(resizedImg, new Rectangle(croppedXPosition, croppedYPosition, croppedImgWidth, croppedImgHeight)); lokacijaPictureBox.Image = croppedImg; using (var ms = new MemoryStream()) { croppedImg.Save(ms, orgImage.RawFormat); novaLokacija.SlikaThumb = ms.ToArray(); } } else { MessageBox.Show("error"); novaLokacija = null; } } }