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)); }