Exemplo n.º 1
0
        public ActionResult Create(Kontakt kontakt, HttpPostedFileBase image)
        {
            kontakt.DatumKreiranja = DateTime.Today;
            kontakt.DatumIzmjene = DateTime.Today;

            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    kontakt.MimeTypeSlika = image.ContentType;
                    kontakt.SlikaDatoteka = new byte[image.ContentLength];
                    image.InputStream.Read(kontakt.SlikaDatoteka, 0, image.ContentLength);
                }
                else
                {
                    kontakt.MimeTypeSlika = "image/jpeg";
                    kontakt.SlikaDatoteka = KontaktInitializer.getFileBytes("\\Slike\\unknown.jpg");
                }

                db.Kontakts.Add(kontakt);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(kontakt);
        }
Exemplo n.º 2
0
 public ActionResult Create()
 {
     // Keriraj novi Graf / Create the new photo
     Kontakt newPhoto = new Kontakt();
     newPhoto.PrezimeIme = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(User.Identity.Name);
     newPhoto.DatumKreiranja = DateTime.Today;
     newPhoto.DatumIzmjene = DateTime.Today;
     return View(newPhoto);
 }
Exemplo n.º 3
0
        public ActionResult Edit(Kontakt kontakt, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    kontakt.MimeTypeSlika = image.ContentType;
                    kontakt.SlikaDatoteka = new byte[image.ContentLength];
                    image.InputStream.Read(kontakt.SlikaDatoteka, 0, image.ContentLength);
                }

                kontakt.DatumKreiranja = kontakt.DatumKreiranja;
                kontakt.DatumIzmjene = DateTime.Today;

                db.Entry(kontakt).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(kontakt);
        }