예제 #1
0
 public ActionResult Create(HttpPostedFileBase file)
 {
     try
     {
         var postareId    = this.Request.Form["Poza.PostareId"];
         int postareIdInt = int.Parse(postareId);
         if (file.ContentLength > 0)
         {
             string filename = Path.GetFileName(file.FileName);
             string path     = Path.Combine(Server.MapPath(Imagine.CaleImagini), filename);
             file.SaveAs(path);
             Poza poza = new Poza();
             poza.CalePoza  = $"{Imagine.CaleImagini}/{filename}";
             poza.PostareId = postareIdInt;
             BlogEntities db = new BlogEntities();
             db.Pozas.Add(poza);
             db.SaveChanges();
         }
         return(RedirectToAction("Edit", "Postare", new { id = postareIdInt }));
     }
     catch
     {
         ViewBag.Message = "Incarcare esuata!!";
         return(View());
     }
 }
        public List <PozaCuComentarii> GetPoze()
        {
            var poze  = new List <PozaCuComentarii>();
            var query = (from file in _ctx.CreateQuery <FileEntity>(_filesTable.Name)
                         select file).AsTableServiceQuery <FileEntity>(_ctx);

            foreach (var file in query)
            {
                var listaComentarii = GetComentariiPePoza(file.RowKey);

                var a = new Poza()
                {
                    Description  = file.RowKey,
                    ThumbnailUrl = file.ThumbnailUrl,
                    Url          = file.Url
                };

                var b = new PozaCuComentarii {
                    Poza = a, Comentarii = listaComentarii
                };

                poze.Add(b);
            }

            return(poze);
        }
예제 #3
0
        public ActionResult GetLink(Poza poza)
        {
            var service = new AlbumFotoService();

            ViewBag.Link = AlbumFotoService.GetBlobSasUri(service.PhotoContainer, poza.Description);

            return(View("Index", service.GetPoze()));
        }
예제 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Poza poza = db.Pozas.Find(id);

            db.Pozas.Remove(poza);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
 public ActionResult Edit([Bind(Include = "Id,PostareId,CalePoza")] Poza poza)
 {
     if (ModelState.IsValid)
     {
         db.Entry(poza).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostareId = new SelectList(db.Postares, "Id", "Titlu", poza.PostareId);
     return(View(poza));
 }
예제 #6
0
        public ActionResult Create([Bind(Include = "Id,PostareId,CalePoza")] Poza poza)
        {
            if (ModelState.IsValid)
            {
                db.Pozas.Add(poza);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostareId = new SelectList(db.Postares, "Id", "Titlu", poza.PostareId);
            return(View(poza));
        }
예제 #7
0
        // GET: Poza/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Poza poza = db.Pozas.Find(id);

            if (poza == null)
            {
                return(HttpNotFound());
            }
            return(View(poza));
        }
예제 #8
0
        public void Save(Manager.Model.Poza poza1)
        {
            Poza poza = new Poza();

            if (poza1 != null)
            {
                poza.Id        = Guid.NewGuid();
                poza.IdProdus  = Guid.Parse(poza1.IdProdus);
                poza.CalePoza  = poza1.CalePoza;
                poza.IsProduct = poza1.IsProduct;
                databaseContext.Poza.Add(poza);
                databaseContext.SaveChanges();
            }
        }
예제 #9
0
        // GET: Poza/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Poza poza = db.Pozas.Find(id);

            if (poza == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PostareId = new SelectList(db.Postares, "Id", "Titlu", poza.PostareId);
            return(View(poza));
        }
예제 #10
0
        public Poza GetPoza(Poza poza)
        {
            Poza poze;
            var  query = (from file in _ctx.CreateQuery <FileEntity>(_filesTable.Name)
                          select file).Where(w => w.RowKey == poza.Description).AsTableServiceQuery <FileEntity>(_ctx).FirstOrDefault();

            poze = new Poza
            {
                Description  = query.RowKey,
                ThumbnailUrl = query.ThumbnailUrl,
                Url          = query.Url,
                Comentarii   = GetComentarii(query.RowKey)
            };

            return(poze);
        }
예제 #11
0
        public void Update(Manager.Model.Poza poza1)
        {
            Poza poza = new Poza();
            Poza check;

            if (poza1 != null)
            {
                poza.Id        = Guid.Parse(poza1.Id);
                poza.IdProdus  = Guid.Parse(poza1.IdProdus);
                poza.CalePoza  = poza1.CalePoza;
                poza.IsProduct = poza1.IsProduct;
                check          = databaseContext.Poza.FirstOrDefault(existingPoza => existingPoza.Id == Guid.Parse(poza1.Id));
                if (check != null)
                {
                    databaseContext.Poza.Remove(check);
                    databaseContext.Poza.Add(poza);
                    databaseContext.SaveChanges();
                }
            }
        }
예제 #12
0
 public Infrastructure.ValidationError[] Update(Poza poza)
 {
     poza = null;
     return(pozaManager.Update(poza));
 }
예제 #13
0
 public Infrastructure.ValidationError[] Save(Poza poza)
 {
     return(pozaManager.Save(poza));
 }
예제 #14
0
        public ActionResult GetComentarii(Poza poza)
        {
            var service = new AlbumFotoService();

            return(View("Comentarii", service.GetComentarii(poza.Description)));
        }