public Publication Post(Publication proj) { MyService.Add(proj); MyService.Commit(); return(proj); }
public ActionResult Create(PublicationVM PublicationVM, HttpPostedFileBase Image) { Publication PublicationDomain = new Publication(); PublicationDomain.title = PublicationVM.title; PublicationDomain.creationDate = DateTime.UtcNow; PublicationDomain.description = PublicationVM.description; PublicationDomain.visibility = (Visibility)PublicationVM.visibility; PublicationDomain.image = Image.FileName; PublicationDomain.nomuser = "******"; //User.Identity.GetUserName(); PublicationDomain.OwnerId = "f43c21cf-f35a-4897-a9e3-343c00afe7b4"; //User.Identity.GetUserId(); PublicationDomain.ownerimg = "exp.png"; // MyUser.GetById(User.Identity.GetUserId()).image; pubserv.Add(PublicationDomain); //notifserv.Add(comp2); pubserv.Commit(); var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Image.FileName); Image.SaveAs(path); return(RedirectToAction("Index")); }
public IHttpActionResult Put(int id, PublicationVM p) { Publication pu = MyService.GetById(id); if (pu != null) { pu.datePub = DateTime.Now; pu.imagePub = p.imagePub; pu.nbLike = p.nbLike; pu.nbDislike = p.nbDislike; pu.titlePub = p.titlePub; pu.descriptionPub = p.descriptionPub; pu.Dislike = p.Dislike; pu.Like = p.Like; pu.nbVue = p.nbVue; MyService.Update(pu); MyService.Commit(); } else { return(NotFound()); } return(Ok()); }
public ActionResult Edit(int id, PublicationVM publicationVM) { publication pub = publicationService.GetById(id); pub.description = publicationVM.description; publicationService.Update(pub); publicationService.Commit(); return(RedirectToAction("Index")); }
public ActionResult Create(PublicationVM publicationvm, HttpPostedFileBase file) { if (!ModelState.IsValid || file == null || file.ContentLength == 0) { RedirectToAction("Create"); } Publication PublicationDomain = new Publication() { datePub = DateTime.Today, imagePub = file.FileName, nbLike = publicationvm.nbLike, nbDislike = publicationvm.nbDislike, titlePub = publicationvm.titlePub, descriptionPub = publicationvm.descriptionPub, Dislike = publicationvm.Dislike, Like = publicationvm.Like, ParentFk = (int)Session["idu"], }; Service.Add(PublicationDomain); Service.Commit(); var fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path. Combine(Server.MapPath("~/Content/Uploads/"), fileName); file.SaveAs(path); } //Service.Dispose(); return(RedirectToAction("Index")); }