public async Task <ActionResult> PostRestoran([FromBody] Restorani_Result obj)
        {
            if (obj == null)
            {
                return(BadRequest());
            }

            Restorani restoran = new Restorani
            {
                Naziv  = obj.Naziv,
                Opis   = obj.Opis,
                Email  = obj.Email,
                WebUrl = obj.WebUrl,
                Adresa = obj.Adresa,
                MinimalnaCijenaNarudžbe = obj.MinimalnaCijenaNarudžbe,
                BlokId    = obj.BlokID,
                Telefon   = obj.Telefon,
                SlikaBin  = obj.SlikaBin,
                VlasnikId = obj.VlasnikID
            };

            context.Restorani.Add(restoran);

            try
            {
                await context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(Ok(restoran.RestoranId));
        }
示例#2
0
        public RestoraniEdit(Restorani_Result editRestoran)
        {
            InitializeComponent();
            if (editRestoran != null)
            {
                restoranModel = editRestoran;
                this.Text     = String.Format(Messages.uredi_restoran_obj, restoranModel.Naziv);
            }

            this.AutoValidate = AutoValidate.Disable;
        }
示例#3
0
        private async void btnSacuvaj_Click(object sender, EventArgs e)
        {
            if (!this.ValidateChildren())
            {
                return;
            }

            bool isPutRequest = true;

            if (restoranModel == null)
            {
                restoranModel = new Restorani_Result();
                isPutRequest  = false;
            }

            restoranModel.Naziv     = txtNaziv.Text;
            restoranModel.Opis      = txtOpis.Text;
            restoranModel.Email     = txtEmail.Text;
            restoranModel.WebUrl    = txtWebUrl.Text;
            restoranModel.Adresa    = txtAdresa.Text;
            restoranModel.BlokID    = Convert.ToInt32(cmbBlokoviGradovi.SelectedValue);
            restoranModel.VlasnikID = 5;                                            //Global.PrijavljeniVlasnik.KorisnikId;
            restoranModel.Telefon   = UIHelper.ExtractPoneNumber(txtMaskTelefon.Text);
            restoranModel.MinimalnaCijenaNarudžbe = (int)Convert.ToDouble(UIHelper.ExtractDecimalCijena(txtMaskMinCijena.Text));

            restoranModel.SlikaBin = ImageHelper.SetSlikaImage(pictureBoxSlika.Image);

            try
            {
                if (isPutRequest)
                {
                    await BaseClient.Client.PutRestoranAsync((int)restoranModel.RestoranID, restoranModel);

                    MessageBox.Show(Messages.uspjesno_napravljene_izmjene_body, Messages.uspjeh_save_title);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    await BaseClient.Client.PostRestoranAsync(restoranModel);

                    MessageBox.Show(Messages.uspjesno_napravljene_izmjene_body, Messages.uspjeh_save_title);
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Messages.greska_msg_title, "Error"),
                                Messages.morate_odabrati_title,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        public async Task <ActionResult <List <Restorani_Result> > > GetRestorani()
        {
            List <Restorani> restorani = await context.Restorani.Include(x => x.Vlasnik).Include(y => y.Blok.Grad).ToListAsync();

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

            return(Ok(Restorani_Result.GetRestoraniResultInstance(restorani)));
        }
        public async Task <ActionResult <Restorani_Result> > GetRestoranById(int restoranId)
        {
            Restorani restoran = await context.Restorani.Include(x => x.Vlasnik).Include(y => y.Blok.Grad).Where(x => x.RestoranId == restoranId).FirstOrDefaultAsync();

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

            return(Ok(Restorani_Result.GetRestoraniResultInstance(restoran)));
        }
示例#6
0
 private void btnNarudzbe_Click(object sender, EventArgs e)
 {
     if (dgvRestorani.SelectedRows.Count > 0)
     {
         Restorani_Result r = (Restorani_Result)dgvRestorani.SelectedRows[0].DataBoundItem;
         NarudzbeList     f = new NarudzbeList(restoran: r);
         //f.MdiParent = Global.Mdi;
         f.Show();
     }
     else
     {
         MessageBox.Show(String.Format(Messages.morate_odabrati_msg_obj, "restoran"),
                         Messages.morate_odabrati_title,
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
        public async Task <ActionResult> PutRestoran(int restoranId, [FromBody] Restorani_Result obj)
        {
            Restorani r = await context.Restorani.FindAsync(restoranId);

            r.Naziv    = obj.Naziv;
            r.Opis     = obj.Opis;
            r.Email    = obj.Email;
            r.WebUrl   = obj.WebUrl;
            r.Telefon  = obj.Telefon;
            r.SlikaBin = obj.SlikaBin;
            r.MinimalnaCijenaNarudžbe = obj.MinimalnaCijenaNarudžbe;
            r.Adresa = obj.Adresa;
            r.BlokId = obj.BlokID;

            await context.SaveChangesAsync();

            return(Ok(r.RestoranId));
        }
 public NarudzbeList(Restorani_Result restoran)
 {
     this.predefinedRestoran = restoran;
     InitializeComponent();
     _init();
 }
        public async Task <ActionResult <List <Restorani_Result> > > GetFavourite(int korisnikId)
        {
            List <Restorani> restorani = await context.RestoraniOmiljeni.Where(X => X.KorisnikId == korisnikId).Select(x => x.Restoran).Include(x => x.Blok.Grad).Include(x => x.Vlasnik).ToListAsync();

            return(Ok(Restorani_Result.GetRestoraniResultInstance(restorani)));
        }
 public HranaList(Restorani_Result restoran)
 {
     InitializeComponent();
     _init((int)restoran.RestoranID, restoran.Naziv);
 }