コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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"));
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public IHttpActionResult stopTopic(StopTopicReq str)
        {
            TopicRepository tr = new TopicRepository();
            topic           t  = tr.setStop(str.topicSn);

            return(Ok(t));
        }
コード例 #6
0
        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"));
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 private topic Edit(topic t)
 {
     t.modiDate        = DateTime.Now;
     db.Entry(t).State = EntityState.Modified;
     db.SaveChanges();
     return(t);
 }
コード例 #11
0
        public ActionResult DeleteConfirmed(int id)
        {
            topic topic = db.topics.Find(id);

            db.topics.Remove(topic);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #12
0
        public topic setStop(int sn)
        {
            topic t = db.topics.Where(p => p.sn == sn).FirstOrDefault();

            t.edate = DateTime.Now;
            db.SaveChanges();
            return(t);
        }
コード例 #13
0
 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>"));
 }
コード例 #14
0
 public ActionResult Edit(topic topicModel)
 {
     using (DBModels dbModels = new DBModels())
     {
         dbModels.Entry(topicModel).State = System.Data.Entity.EntityState.Modified;
         dbModels.SaveChanges();
     }
     return(RedirectToAction("index"));
 }
コード例 #15
0
        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"));
        }
コード例 #16
0
        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 }));
        }
コード例 #17
0
        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);
        }
コード例 #18
0
 public ActionResult Create(topic topicModel)
 {
     using (DBModels dbModels = new DBModels())
     {
         dbModels.topics.Add(topicModel);
         dbModels.SaveChanges();
     }
     return(RedirectToAction("index"));
 }
コード例 #19
0
        // 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));
        }
コード例 #20
0
        public ActionResult Details(int num = 0)
        {
            topic topic = Db.topic.Find(num);

            if (topic == null)
            {
                return(HttpNotFound());
            }
            return(View(topic));
        }
コード例 #21
0
        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>"));
        }
コード例 #22
0
 public topic setData(topic t)
 {
     if (t.sn == 0)
     {
         return(AddNew(t));
     }
     else
     {
         return(Edit(t));
     }
 }
コード例 #23
0
 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));
 }
コード例 #24
0
        public IHttpActionResult Gettopic(int id)
        {
            topic topic = db.topics.Find(id);

            if (topic == null)
            {
                return(NotFound());
            }

            return(Ok(topic));
        }
コード例 #25
0
        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));
        }
コード例 #26
0
        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));
        }
コード例 #27
0
        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());
                }
            }
        }
コード例 #28
0
        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"));
        }
コード例 #29
0
        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));
        }
コード例 #30
0
        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));
        }
コード例 #31
0
ファイル: JanetsXMLGenius.cs プロジェクト: xchgdzq233/testing
 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();
 }