Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id)
        {
            var model = new FilmoviViewModel(await _service.GetById <Model.Filmovi>(id));

            ViewBag.Zanrovi = new SelectList(await _zanroviservice.Get <List <Model.Zanrovi> >(null), "ZanrID", "Naziv");

            //Passing image data in viewbag to view
            string imgDataURL = string.Format("data:image/png;base64,{0}", model.SlikaUrl);

            ViewBag.ImageData = imgDataURL;
            return(View("FilmoviDetalji", model));
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Snimi(FilmoviViewModel model)
 {
     //ModelState.Remove("FilmID");
     if (ModelState.IsValid)
     {
         request.ZanrID          = model.ZanrID;
         request.Naziv           = model.Naziv;
         request.Opis            = model.Opis;
         request.Reziser         = model.Reziser;
         request.Trajanje        = model.Trajanje != null? model.Trajanje.Value:0;
         request.Glumci          = model.Glumci;
         request.GodinaIzdavanja = model.GodinaIzdavanja;
         request.VideoUrl        = model.VideoUrl;
         if (model.ZanrID != 0)
         {
             request.ZanrID = model.ZanrID;
         }
         if (model.Slika != null)
         {
             request.Slika = IFormFileToByte(model.Slika);
         }
         if (model.FilmID != null)
         {
             try
             {
                 await _service.Update <Model.Filmovi>(model.FilmID.Value, request);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
         else
         {
             try
             {
                 await _service.Insert <Model.Filmovi>(request);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.Zanrovi = new SelectList(await _zanroviservice.Get <List <Model.Zanrovi> >(null), "ZanrID", "Naziv");
     return(View("FilmoviDetalji"));
 }
Exemplo n.º 3
0
 public FilmoviPage()
 {
     InitializeComponent();
     BindingContext = model = new FilmoviViewModel();
 }
Exemplo n.º 4
0
 public FilmoviPage(int klijentId)
 {
     InitializeComponent();
     _klijentId     = klijentId;
     BindingContext = model = new FilmoviViewModel();
 }
Exemplo n.º 5
0
        public async Task <IActionResult> Delete(int id)
        {
            var model = new FilmoviViewModel(await _service.Delete <Model.Filmovi>(id));

            return(RedirectToAction("Index"));
        }