Exemplo n.º 1
0
        public IHttpActionResult PutModeli(int id, Modeli modeli)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != modeli.ModelID)
            {
                return(BadRequest());
            }

            db.Entry(modeli).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModeliExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Modeli modeli = db.Modelis.Find(id);

            db.Modelis.Remove(modeli);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public async Task <IActionResult> OnPostAsync(Modeli modeli)
 {
     if (modeli != null)
     {
         await _services.AddModele(modeli);
     }
     return(RedirectToPage("Index"));
 }
Exemplo n.º 4
0
        public async Task <Modeli> AddModele(Modeli modeli)
        {
            await _context.Modelet.AddAsync(modeli);

            await _context.SaveChangesAsync();

            return(modeli);
        }
Exemplo n.º 5
0
        public IHttpActionResult GetModeli(int id)
        {
            Modeli modeli = db.Modeli.Find(id);

            if (modeli == null)
            {
                return(NotFound());
            }

            return(Ok(modeli));
        }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Id,Name,MakeId,Abvr")] Modeli modeli)
 {
     if (ModelState.IsValid)
     {
         db.Entry(modeli).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MakeId = new SelectList(db.Makes, "Id", "Name", modeli.MakeId);
     return(View(modeli));
 }
Exemplo n.º 7
0
        public IHttpActionResult PostModeli(Modeli modeli)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Modeli.Add(modeli);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = modeli.ModelID }, modeli));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Id,Name,MakeId,Abvr")] Modeli modeli)
        {
            if (ModelState.IsValid)
            {
                db.Modelis.Add(modeli);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MakeId = new SelectList(db.Makes, "Id", "Name", modeli.MakeId);
            return(View(modeli));
        }
Exemplo n.º 9
0
        // GET: Modelis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Modeli modeli = db.Modelis.Find(id);

            if (modeli == null)
            {
                return(HttpNotFound());
            }
            return(View(modeli));
        }
Exemplo n.º 10
0
        public IHttpActionResult DeleteModeli(int id)
        {
            Modeli modeli = db.Modeli.Find(id);

            if (modeli == null)
            {
                return(NotFound());
            }

            db.Modeli.Remove(modeli);
            db.SaveChanges();

            return(Ok(modeli));
        }
Exemplo n.º 11
0
        // GET: Modelis/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Modeli modeli = db.Modelis.Find(id);

            if (modeli == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MakeId = new SelectList(db.Makes, "Id", "Name", modeli.MakeId);
            return(View(modeli));
        }
Exemplo n.º 12
0
        public Modeli UpdateModelet(Modeli updatedModeli)
        {
            // var modeli = _context.Modelet.FirstOrDefault(x => x.ModeliId == updatedModeli.ModeliId);
            var modeli = _context.Modelet
                         .Include(m => m.Marka)
                         .FirstOrDefault(x => x.ModeliId == updatedModeli.ModeliId);

            if (modeli != null)
            {
                modeli.ModeliEmer = updatedModeli.ModeliEmer;
                modeli.MarkaId    = updatedModeli.MarkaId;
                _context.SaveChanges();
            }
            return(modeli);
        }
Exemplo n.º 13
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Modeli = await _context.Modelet
                     .Include(m => m.Marka).FirstOrDefaultAsync(m => m.ModeliId == id);

            if (Modeli == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 14
0
        private void doajSlikuModelaBtn_Click(object sender, EventArgs e)
        {
            try
            {
                model = new Modeli();


                openFileDialog1.ShowDialog();
                slikaModelaInput.Text = openFileDialog1.FileName;

                Image image = Image.FromFile(slikaModelaInput.Text);

                MemoryStream ms = new MemoryStream();
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                model.Slika = ms.ToArray();


                int resizedImgWidth  = Convert.ToInt32(ConfigurationManager.AppSettings["resizeImgWidthModel"]);
                int resizedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["resizeImgHeightModel"]);
                int croppedImgWidth  = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgWidth"]);
                int croppedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgHeight"]);

                if (image.Width > resizedImgWidth)
                {
                    Image resizedImage = UIHelper.ResizeImage(image, new Size(resizedImgWidth, resizedImgHeight));
                    ModelpictureBox.Image = resizedImage;
                }
                else
                {
                    MessageBox.Show(Global.GetPoruka("picture_war") + " " + resizedImgWidth + "x" + resizedImgHeight + ".", Global.GetPoruka("warning"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    proizvod = null;
                }
            }
            catch (Exception)
            {
                proizvod = null;
                ModelpictureBox.Image = null;
                slikaModelaInput.Text = "";
            }
        }
Exemplo n.º 15
0
        private void dodajModelBtn_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                if (model == null)
                {
                    model = new Modeli();
                }
                if (revijeCbx.SelectedIndex != 0)
                {
                    model.RevijaID = Convert.ToInt32(revijeCbx.SelectedValue);
                }
                model.Opis  = opisInput.Text;
                model.Naziv = nazivInput.Text;

                HttpResponseMessage response = modeliService.PostResponse(model);

                if (model.Slika == null)
                {
                    MessageBox.Show("Obavezno unijeti sve podatke !");
                }
                else
                {
                    if (response.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Uspješno ste dodali novi look", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Clear();


                        AddStavkeModela sm = new AddStavkeModela();
                        sm.Show();
                    }
                    else
                    {
                        MessageBox.Show(response.ReasonPhrase, Global.GetPoruka("error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            HttpResponseMessage response = modeliServis.GetActionResponse("GetModeliPhone", e.Parameter.ToString());

            if (response.IsSuccessStatusCode)
            {
                Modeli m = response.Content.ReadAsAsync <Modeli>().Result;

                nazivvLabel.Text = m.Naziv;
                //nazivLabel.Text = m.Naziv;
                imeLabel.Text = m.Dizajner + " " + "(Prosječna ocjena: " + Math.Round((float)m.Prosjek, 2).ToString() + ")";
                // prezimeLabel.Text = m.Prezime;
                opisLabel.Text     = m.Opis;
                lookbookLabel.Text = m.Lookbook;
                revijaLabel.Text   = m.Revija;
                dizajnerID         = m.KorisnikID;



                MemoryStream ms    = new MemoryStream(m.Slika);
                BitmapImage  image = new BitmapImage();

                await image.SetSourceAsync(ms.AsRandomAccessStream());

                modelImage.Source = image;


                if (Global.prijavljeniKupac != null)
                {
                    labelOcjene.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    gridOcjene.Visibility  = Windows.UI.Xaml.Visibility.Visible;
                }
            }

            BindProizvodi(e.Parameter.ToString());
        }
Exemplo n.º 17
0
        public IActionResult Edit(Modeli model, int page = 1, int sort = 1, bool ascending = true)
        {
            if (model == null)
            {
                return(NotFound("Nema poslanih podataka"));
            }
            bool checkId = _ctx.Modeli.Any(m => m.IdModela == model.IdModela);

            if (!checkId)
            {
                return(NotFound($"Neispravan id modela: {model?.IdModela}"));
            }

            PrepareDropDownLists();
            if (ModelState.IsValid)
            {
                try
                {
                    _ctx.Update(model);
                    _ctx.SaveChanges();

                    TempData[Constants.Message]       = "model ažurirana.";
                    TempData[Constants.ErrorOccurred] = false;
                    return(RedirectToAction(nameof(Index), new { page, sort, ascending }));
                }
                catch (Exception exc)
                {
                    ModelState.AddModelError(string.Empty, exc.Message);
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 18
0
 public IActionResult Create(Modeli model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _ctx.Add(model);
             _ctx.SaveChanges();
             TempData[Constants.Message]       = $"model uspjesno dodana.*";
             TempData[Constants.ErrorOccurred] = false;
             return(RedirectToAction(nameof(Index)));
         }
         catch (Exception e)
         {
             ModelState.AddModelError(string.Empty, e.Message);
             PrepareDropDownLists();
             return(View(model));
         }
     }
     else
     {
         return(View(model));
     }
 }
        public async Task <IActionResult> DodajMarkuModelTip(int ModelId = 0, int MarkaId = 0, string NoviTip = "", string NovaMarkaModel = "")
        {
            if (NovaMarkaModel != " ")
            {
                NovaMarkaModel = NovaMarkaModel.First().ToString().ToUpper() + String.Join("", NovaMarkaModel.Skip(1)).ToLower();
                if (MarkaId == 0)
                {
                    try
                    {
                        Marka m1 = new Marka
                        {
                            Naziv = NovaMarkaModel
                        };
                        db.Marke.Add(m1);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index", "Home"));
                    }
                    catch (Exception)
                    {
                        ViewBag.Greska = "Doslo je do greske prilikom cuvanja Marke";
                    }
                }
                if (MarkaId != 0 && ModelId == 0)
                {
                    try
                    {
                        Modeli m1 = new Modeli
                        {
                            MarkaId = MarkaId,
                            Naziv   = NovaMarkaModel
                        };
                        db.Models.Add(m1);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index", "Home"));
                    }
                    catch (Exception)
                    {
                        ViewBag.Greska = "Doslo je do greske prilikom cuvanja Modela";
                    }
                }
            }
            if (NoviTip != "")
            {
                NoviTip = NoviTip.First().ToString().ToUpper() + String.Join("", NoviTip.Skip(1)).ToLower();
                try
                {
                    TipVozila t1 = new TipVozila
                    {
                        Naziv = NoviTip
                    };
                    db.TipoviVozila.Add(t1);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                catch (Exception)
                {
                    ViewBag.Greska = "Doslo je do greske prilikom cuvanja Tipa vozila";
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 20
0
 public IActionResult OnPost(Modeli modeli)
 {
     _services.UpdateModelet(modeli);
     return(RedirectToPage("Index"));
 }