public ActionResult Edit([Bind(Include = "Id,Ime,Prezime,AdvokatImage")] Advokat advokat, HttpPostedFileBase image)
        {
            if (image != null)
            {
                var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png", "image/gif", "image/tif" };

                if (allowedContentTypes.Contains(image.ContentType))
                {
                    var imagesPath   = "/Content/images/";
                    var filename     = Guid.NewGuid().ToString() + image.FileName;
                    var uploadPath   = imagesPath + filename;
                    var physicalPath = Server.MapPath(uploadPath);
                    image.SaveAs(physicalPath);
                    advokat.AdvokatImage = uploadPath;

                    _db.Edit(advokat);

                    TempData["Success"] = "Uspešno izmenjen advokat";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(RedirectToAction("Edit"));
            }


            return(View(advokat));
        }
        protected override object Execute(DomenskiObjekat domenskiObjekat)
        {
            Advokat        advokat  = (Advokat)domenskiObjekat;
            List <Advokat> advokati = broker.VratiSve(domenskiObjekat).OfType <Advokat>().ToList();

            return(advokati);
        }
        public void Remove(int id)
        {
            Advokat a = _context.Advokati.Find(id);

            _context.Advokati.Remove(a);
            _context.SaveChanges();
        }
        // GET: Advokats/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Advokat advokat = _db.FindById(Convert.ToInt32(id));

            if (advokat == null)
            {
                return(HttpNotFound());
            }
            return(View(advokat));
        }
        public ActionResult Create([Bind(Include = "Id,Ime,Prezime,AdvokatImage")] Advokat advokat, HttpPostedFileBase image, Korisnik korisnik)
        {
            if (image != null)
            {
                var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png", "image/gif", "image/tif" };

                if (allowedContentTypes.Contains(image.ContentType))
                {
                    var imagesPath   = "/Content/images/";
                    var filename     = Guid.NewGuid().ToString() + image.FileName;
                    var uploadPath   = imagesPath + filename;
                    var physicalPath = Server.MapPath(uploadPath);
                    image.SaveAs(physicalPath);
                    advokat.AdvokatImage = uploadPath;

                    _db.Add(advokat);

                    korisnik.Username = advokat.Ime;
                    korisnik.Password = advokat.Prezime;
                    korisnik.UlogaId  = 2;
                    korisnik.Id       = advokat.Id;

                    _kDb.Add(korisnik);

                    TempData["Success"] = "Uspešno dodat advokat";
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(RedirectToAction("Create"));
            }


            return(View(advokat));
        }
 public void Edit(Advokat a)
 {
     _context.Entry(a).State = System.Data.Entity.EntityState.Modified;
     _context.SaveChanges();
 }
 public void Add(Advokat a)
 {
     _context.Advokati.Add(a);
     _context.SaveChanges();
 }