public ActionResult Create(MVCConsumeWebAPI.Models.topic t, HttpPostedFileBase files) { topic topic = new topic(); // try { HttpClient Client = new HttpClient(); HttpResponseMessage response = Client.PostAsJsonAsync <MVCConsumeWebAPI.Models.topic>(" http://localhost:18080/gestion-resources-humaine-web/api/test/topic/ajouter", t).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()).Result; if (response.IsSuccessStatusCode) { // string fileName = ""; if (files != null) { fileName = Path.GetFileName(files.FileName); var physicalPath = Path.Combine(Server.MapPath("~/Content/chahnez"), fileName); var fileExtension = Path.GetExtension(files.FileName); files.SaveAs(physicalPath); } topic.image = fileName; return(RedirectToAction("Index")); } } // catch { return(View()); } }
public ActionResult AddTopic(HttpPostedFileBase photo) { try { var sujet = Request.Form["subject"]; var contenu = Request.Form["message"]; var soucat = Request.Form["subject1"]; var x = Ss.getByName(soucat); var top = new topic(); top.contenu = (sujet); top.sujet = (contenu); var restClient = new RestClient("http://localhost:18080/insurance-web/api/"); restClient.AddDefaultHeader("accept", "*/*"); var request = new RestRequest("Topic?id=" + x[0].idSousCategory, Method.POST); request.AddJsonBody(new { sujet = sujet, contenu = contenu }); var response = restClient.Execute(request); return(RedirectToAction("First")); } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); return(RedirectToAction("AddTopic")); } }
public ActionResult Listwaiting() { topic t = new topic(); List <MVCConsumeWebAPI.Models.reclamation> listR = new List <MVCConsumeWebAPI.Models.reclamation>(); foreach (var item in reclamationservice.GetAll()) { MVCConsumeWebAPI.Models.reclamation Rc = new MVCConsumeWebAPI.Models.reclamation(); Rc.etat = item.etat; if (Rc.etat.Equals("En attente")) { Rc.id = item.id; Rc.image = item.image; Rc.etat = item.etat; Rc.description = item.description; Rc.objet = item.objet; Rc.date_creation = item.date_creation; //t = topicservice.GetById(item.topic.id); //Rc.topic_id = t.id; listR.Add(Rc); } } return(View(listR)); }
ITopicService GetTopicService() { var mockContext = new Mock <IUnitOfWork>(); var expectedTopic = new topic() { Topic_ID = 1, Topic_Name = "testN", Topic_Description = "testD", Category_ID = 2 }; var mockDbSet = new Mock <ITopicRepository>(); mockDbSet.Setup(z => z.Find( It.IsAny <Func <topic, bool> >(), It.IsAny <int>(), It.IsAny <int>())) .Returns( new List <topic>() { expectedTopic } ); mockContext .Setup(context => context.topics) .Returns(mockDbSet.Object); ITopicService topicService = new TopicService(mockContext.Object); return(topicService); }
public IHttpActionResult stopTopic(StopTopicReq str) { TopicRepository tr = new TopicRepository(); topic t = tr.setStop(str.topicSn); return(Ok(t)); }
public ActionResult Create(question q) { q.id = 0; topic t = new topic(); t.id = ids; q.topic = t; jsonq = q; // try { HttpClient Client = new HttpClient(); HttpResponseMessage response = Client.PostAsJsonAsync <question>(" http://localhost:18080/gestion-resources-humaine-web/api/test/question/ajouter", q).ContinueWith((postTask) => postTask.Result.EnsureSuccessStatusCode()).Result; //return RedirectToAction("Index", "Topic"); if (response.IsSuccessStatusCode) { return(RedirectToAction("Index", "Topic")); } } // catch { return(RedirectToAction("Index", "Topic")); } }
public IHttpActionResult Puttopic(int id, topic topic) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != topic.sn) { return(BadRequest()); } db.Entry(topic).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!topicExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int num) { topic topic = Db.topic.Find(num); foreach (var rating in Db.rating.Where(x => x.ItemId == topic.Id && x.Type == "topic")) { Db.rating.Remove(rating); } foreach (var comment in topic.comments) { Db.comment.Remove(comment); foreach (var commentpost in Db.post.Where(x => x.ItemId == num.ToString() + "-" + comment.Id.ToString() && x.Type == "create-comment")) { Db.post.Remove(commentpost); } foreach (var likepost in Db.post.Where(x => x.ItemId == comment.Id.ToString() && (x.Type == "like-comment" || x.Type == "dislike-comment"))) { Db.post.Remove(likepost); } } foreach (var likepost in Db.post.Where(x => x.ItemId == topic.Id.ToString() && (x.Type == "like-topic" || x.Type == "dislike-topic"))) { Db.post.Remove(likepost); } Db.topic.Remove(topic); Db.SaveChanges(); if (topic.IsApproval == true) { OK.UpdateRating((int)topic.WriterId, -25); } OK.DeletePost((int)topic.WriterId, topic.ForumId.ToString() + "-" + topic.Id.ToString(), "create-topic"); return(RedirectToAction("index")); }
public topic GetTopicByTopicName(string topicName) { try { topic topicFromDB = context.topics.FirstOrDefault(x => x.topicName.ToLower() == topicName.ToLower()); if (topicFromDB != null) { return(topicFromDB); } else { topicFromDB = new topic(); topicFromDB.topicName = topicName; topicFromDB.topicID = context.topics.Count() + 1; topicFromDB.is_Active = true; topicFromDB.created_on = DateTime.Now; context.topics.Add(topicFromDB); if (context.SaveChanges() > 0) { return(topicFromDB); } else { throw new Exception("Topic Not Created"); } } } catch (Exception) { throw; } }
private topic Edit(topic t) { t.modiDate = DateTime.Now; db.Entry(t).State = EntityState.Modified; db.SaveChanges(); return(t); }
public ActionResult DeleteConfirmed(int id) { topic topic = db.topics.Find(id); db.topics.Remove(topic); db.SaveChanges(); return(RedirectToAction("Index")); }
public topic setStop(int sn) { topic t = db.topics.Where(p => p.sn == sn).FirstOrDefault(); t.edate = DateTime.Now; db.SaveChanges(); return(t); }
public ActionResult EditTopicSave(topic model) { model.Seo = OK.ConvertSeo(model.Title); model.ModifyDate = DateTime.Now; model.IsApproval = false; Db.SaveChanges(); return(Content("<script type=\"text/javascript\">$.OK.SuccessModal('Konunuz başarıyla düzenlendi.. Onaylandıktan sonra yayınlanacak..');</script>")); }
public ActionResult Edit(topic topicModel) { using (DBModels dbModels = new DBModels()) { dbModels.Entry(topicModel).State = System.Data.Entity.EntityState.Modified; dbModels.SaveChanges(); } return(RedirectToAction("index")); }
public ActionResult deleteTrash(int id) { topic mtopic = db.Topics.Find(id); db.Topics.Remove(mtopic); db.SaveChanges(); Message.set_flash("Đã xóa vĩnh viễn 1 Chủ đề", "success"); return(RedirectToAction("trash")); }
public ActionResult UpdateTopic(int id) { topic t = gt.FindById(id); t.closed = !t.closed; gt.Update(t); gt.Commit(); return(RedirectToAction("ShowTopic", "Topic", new{ id = t.id })); }
public topic setReopen(int sn) { topic t = db.topics.Where(p => p.sn == sn).FirstOrDefault(); gameDto g = new GameRepository().GetGame(t.gameSn.Value); t.edate = g.edate; db.SaveChanges(); return(t); }
public ActionResult Create(topic topicModel) { using (DBModels dbModels = new DBModels()) { dbModels.topics.Add(topicModel); dbModels.SaveChanges(); } return(RedirectToAction("index")); }
// GET: Topic/Delete/5 public ActionResult Delete(int id) { topic topicModel = new topic(); using (DBModels dbModels = new DBModels()) { topicModel = dbModels.topics.Where(x => x.TopicID == id).FirstOrDefault(); } return(View(topicModel)); }
public ActionResult Details(int num = 0) { topic topic = Db.topic.Find(num); if (topic == null) { return(HttpNotFound()); } return(View(topic)); }
public ActionResult ChangeApproval(int num = 0) { string result = ""; topic topic = Db.topic.Find(num); if (topic != null) { if (topic.IsApproval == true) { topic.IsApproval = false; result = "Konunun onayı başarıyla kaldırıldı."; OK.UpdateRating((int)topic.WriterId, -25); OK.ChangePostApproval((int)topic.WriterId, topic.ForumId + "-" + topic.Id, "create-topic", false); foreach (var comment in topic.comments.ToList()) { foreach (var commentpost in Db.post.Where(x => x.ItemId == num + "-" + comment.Id && x.Type == "create-comment").ToList()) { commentpost.IsApproval = false; } foreach (var likecommentpost in Db.post.Where(x => x.ItemId == "" + comment.Id + "" && (x.Type == "like-comment" || x.Type == "dislike-comment")).ToList()) { likecommentpost.IsApproval = false; } } foreach (var likepost in Db.post.Where(x => x.ItemId == "" + topic.Id + "" && (x.Type == "like-topic" || x.Type == "dislike-topic")).ToList()) { likepost.IsApproval = false; } } else { topic.IsApproval = true; result = "Konu başarıyla onaylandı."; OK.UpdateRating((int)topic.WriterId, +25); OK.ChangePostApproval((int)topic.WriterId, topic.ForumId.ToString() + "-" + topic.Id.ToString(), "create-topic", true); foreach (var comment in topic.comments) { foreach (var commentpost in Db.post.Where(x => x.ItemId == num + "-" + comment.Id && x.Type == "create-comment").ToList()) { commentpost.IsApproval = true; } foreach (var likecommentpost in Db.post.Where(x => x.ItemId == "" + comment.Id + "" && (x.Type == "like-comment" || x.Type == "dislike-comment")).ToList()) { likecommentpost.IsApproval = true; } } foreach (var likepost in Db.post.Where(x => x.ItemId == "" + topic.Id + "" && (x.Type == "like-topic" || x.Type == "dislike-topic"))) { likepost.IsApproval = true; } } Db.SaveChanges(); } return(Content("<script type=\"text/javascript\">SuccessInfo('" + result + "');</script>")); }
public topic setData(topic t) { if (t.sn == 0) { return(AddNew(t)); } else { return(Edit(t)); } }
public ActionResult Edit([Bind(Include = "TopicID,TrainerID,TopicDescription,TopicName")] topic topic) { if (ModelState.IsValid) { db.Entry(topic).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TrainerID = new SelectList(db.trainers, "TrainerID", "TrainerName", topic.TrainerID); return(View(topic)); }
public IHttpActionResult Gettopic(int id) { topic topic = db.topics.Find(id); if (topic == null) { return(NotFound()); } return(Ok(topic)); }
public IHttpActionResult addData(String name, String picture) { topic top = new topic(); top.name_topic = name; top.picture = picture; this.api.topics.Add(top); this.api.SaveChanges(); // this.api.words.Where(m => !this.api.learns.Any(m2 => m2.id_word == m.id_word)); return(Ok(top)); }
public ActionResult Edit(int num = 0) { topic topic = Db.topic.Find(num); if (topic == null) { return(HttpNotFound()); } ViewBag.ForumId = new SelectList(Db.forum, "Id", "Name", topic.ForumId); return(View(topic)); }
public async Task <ActionResult> Save(topic topic, HttpPostedFileBase imgageFile) { string ImagePath = null; try { if (imgageFile != null) { ImagePath = topic.TopicTitle + "_" + topic.TopicId + ".png"; string path = Path.Combine(Server.MapPath("~/TopicsImages"), Path.GetFileName(ImagePath)); imgageFile.SaveAs(path); Debug.Write("Image Saved Successfully"); } else { var SelectedTopic = db.TopicsDetails.SingleOrDefault(x => x.TopicDetailsId == topic.TopicId); ImagePath = SelectedTopic.Image; } } catch (Exception) { Debug.Write("Error while Image uploading."); } if (topic.TopicId == 0) { //Create topic.TopicDetails.Image = ImagePath; db.Topics.Add(topic); await db.SaveChangesAsync(); return(RedirectToAction("ListAlltopics")); } else { //Edit var Target_topic = await db.Topics.Include(d => d.TopicDetails).FirstOrDefaultAsync(I => I.TopicId == topic.TopicId); if (topic != null) { Target_topic.TopicDate = topic.TopicDate; Target_topic.TopicDetails = topic.TopicDetails; Target_topic.TopicIsActive = topic.TopicIsActive; Target_topic.TopicTitle = topic.TopicTitle; Target_topic.TopicDetails.Image = ImagePath; await db.SaveChangesAsync(); return(RedirectToAction("ListAlltopics")); } else { return(HttpNotFound()); } } }
public ActionResult Delete(int id, FormCollection collection) { using (DBModels dbModel = new DBModels()) { topic topicModel = dbModel.topics.Where(x => x.TopicID == id).FirstOrDefault(); dbModel.topics.Remove(topicModel); dbModel.SaveChanges(); } return(RedirectToAction("index")); }
public ActionResult Create([Bind(Include = "TopicID,TrainerID,TopicDescription,TopicName")] topic topic) { if (ModelState.IsValid) { db.topics.Add(topic); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TrainerID = new SelectList(db.trainers, "TrainerID", "TrainerName", topic.TrainerID); return(View(topic)); }
public IHttpActionResult Posttopic(topic topic) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.topics.Add(topic); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = topic.sn }, topic)); }
public void CreateSampleTopic() { topic t = new topic(); t.title = "Test"; t.shortdesc = "Description"; t.prolog = new prolog(); t.body = new body(); String path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Stream output = File.OpenWrite(Path.Combine(path, "topic.xml")); XmlSerializer ser = new XmlSerializer(typeof(topic)); ser.Serialize(output, t); output.Flush(); }