public void editCommentWithIdAndComment(int idComment, string description)
 {
     Comments comment = new Comments();
     comment = db.comments.FirstOrDefault(m => m.id == idComment);
     comment.description = description;
     db.SaveChanges();
 }
 public void findAllCommentsArroundTest()
 {
     Locations location = new Locations();
     Codes code = new Codes();
     Comments comment = new Comments();
     List<Comments> comments = new List<Comments>();
     location.id = 20;
     location.latitude = 25;
     location.longitude = 20;
     code.code = "7DE352BC35E966716789926415D69D96";
     code.id = 5;
     comment.archiveDescription = "archive";
     comment.description = "descr";
     comment.id = 30;
     comment.isText = true;
     comment.locationsId = 23;
     comment.userId = 10;
     comments.Add(comment);
     iLocationServices.Setup(m => m.findLocationByLatAndLng(It.IsAny<string>(), It.IsAny<string>())).Returns(location);
     iCommentServices.Setup(m => m.findCommentByIdLocation(It.IsAny<int>())).Returns(comments);
     iCodeServices.Setup(m => m.findFirstCode()).Returns("code");
     CommentsWebServicesController target = new CommentsWebServicesController(iCodeServices.Object, iLocationServices.Object, iCommentServices.Object);
     string actual = target.findAllCommentsArround(null, "3", "7DE352BC35E966716789926415D69D96");
     Assert.IsNull(actual);
 }
        public string addCommentoToLocation(string location, string comment, string code)
        {
            string firstCode = codeServices.findFirstCode();
            Locations locationPassed = new Locations();
            Locations locationSearch = new Locations();
            Comments commentPassed = new Comments();

            if (code == firstCode)
            {
                locationPassed = serializer.Deserialize<Locations>(location);
                commentPassed = serializer.Deserialize<Comments>(comment);
                locationSearch = locationServices.findLocationByLatAndLng(locationPassed.latitude.ToString(), locationPassed.longitude.ToString());
                if (locationPassed == null || locationPassed.id == 0)
                {
                    locationServices.addLocations(locationPassed);
                    commentPassed.locationsId = locationPassed.id;
                    commentPassed.isText = true;
                }
                else
                {
                    commentPassed.locationsId = locationSearch.id;
                    commentPassed.isText = true;
                }
                commentServices.addComment(commentPassed);
                return "1";

            }
            return "0";
        }
 public void deleteComment(int idComment)
 {
     Comments comment = new Comments();
     comment = db.comments.FirstOrDefault(m => m.id == idComment);
     db.comments.Remove(comment);
     db.SaveChanges();
 }
 public string sendLastSoundCommentFromIdLocation(int idLocation, string code)
 {
     List<Comments> comments = new List<Comments>();
     Comments lastComment = new Comments();
     comments = commentServices.findCommentByIdLocation(idLocation);
     lastComment = comments.LastOrDefault();
     if (lastComment != null)
         return lastComment.sound;
     else
         return null;
 }
 public void addTextCommentTest()
 {
     iCommentServices.Setup(m => m.addComment(It.IsAny<Comments>()));
     CommentController target = new CommentController(iCommentServices.Object, iLocationServices.Object);
     Comments comment = new Comments();
     comment.description = "teste";
     var actual = target.addTextComment(comment, "Normal Mode") as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "index");
     Assert.AreEqual(actual.RouteValues["controller"], "Maps");
 }
 public void addComentAndSoundToLocation(string location, byte[] sound, Comments comments, string code)
 {
     Comments commentPassed = new Comments();
     commentPassed.sound = convertBytesToString(sound);
     commentPassed.typeOfCommentsId = comments.typeOfCommentsId;
     commentPassed.isText = comments.isText;
     commentPassed.userId = comments.userId;
     commentPassed.description = comments.description;
     string comment = serializer.Serialize(commentPassed);
     CommentsWebServicesController commentsWebServicesController = new CommentsWebServicesController();
     commentsWebServicesController.addCommentAndSoundToLocation(location, comment, code);
 }
 public void addTextCommentWithLocationTest()
 {
     iCommentServices.Setup(m => m.addComment(It.IsAny<Comments>()));
     CommentController target = new CommentController(iCommentServices.Object, iLocationServices.Object);
     Comments comment = new Comments();
     Random random = new Random();
     int locationId = random.Next();
     comment.description = "Teste";
     var actual = target.addTextCommentWithLocation(comment, locationId) as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "index");
     Assert.AreEqual(actual.RouteValues["controller"], "Maps");
 }
 public void sendLastCommentFromIdLocationTest()
 {
     List<Comments> comments = new List<Comments>();
     Comments comment = new Comments();
     comment.description = "Teste";
     comments.Add(comment);
     iCommentServices.Setup(m => m.findCommentByIdLocation(It.IsAny<int>())).Returns(comments);
     SpeechWebServicesController target = new SpeechWebServicesController(iCommentServices.Object);
     string idLocation = "1";
     string code = "teste";
     var actual = target.sendLastCommentFromIdLocation(idLocation, code);
     Assert.IsNotNull(actual);
 }
 public string sendLastCommentFromIdLocation(string idLocation, string code)
 {
     List<Comments> comments = new List<Comments>();
     Comments lastComment = new Comments();
     Stream resultStream;
     byte[] result;
     string resultJson;
     List<string> listChar = new List<string>();
     SpeechSynthesizer speech = new SpeechSynthesizer("SmartAudioCityGuide", "Lz+vYpOFm6NTP83A9y0tPoX6ByJa06Q6yxHvoBsD0xo=");
     comments = commentServices.findCommentByIdLocation(Convert.ToInt32(idLocation));
     lastComment = comments.Last();
     resultStream = speech.GetSpeakStream(lastComment.description,"pt");
     result = convertStreamToByteBuffer(resultStream);
     for (int i = 0; i < result.Length; i++)
     {
         listChar.Add(result[i].ToString());
     }
     resultJson = javaSerializer.Serialize(listChar);
     return resultJson;
 }
        public ActionResult addTextComment(Comments comment,string selectList)
        {
            SpeechSynthesizer speech = new SpeechSynthesizer("SmartAudioCityGuide", "Lz+vYpOFm6NTP83A9y0tPoX6ByJa06Q6yxHvoBsD0xo=");
            Stream stream;
            byte[] bytes;
            comment.isText = false;

            if (selectList == "--Select One--")
            {
                return RedirectToAction("index", "Maps");
            }

            else if(selectList == "Normal Mode")
            {
                comment.typeOfCommentsId = 1;
            }

            else if (selectList == "Exploration Mode")
            {
                comment.typeOfCommentsId = 2;
            }

            stream = speech.GetSpeakStream(comment.description);
            bytes = ReadFully(stream);
            comment.sound = convertBytesToString(bytes);

            try
            {
                locationServices.addLocations(location.currentLocation);
                comment.locationsId = location.currentLocation.id;
                comment.userId = user.currentUser.id;
            }
            catch
            {

            }

            commentsServices.addComment(comment);

            return RedirectToAction("index", "Maps");
        }
 public Comments findCommentByIdComment(int idComment)
 {
     Comments comment = new Comments();
     comment = db.comments.FirstOrDefault(m => m.id == idComment);
     return comment;
 }
 public void editCommentWithIdTest()
 {
     iCommentServices.Setup(m=>m.editCommentWithIdAndComment(It.IsAny<int>(),It.IsAny<string>()));
     iCommentServices.Setup(m => m.findCommentByIdComment(It.IsAny<int>())).Returns(new Comments());
     CommentController target = new CommentController(iCommentServices.Object,iLocationServices.Object);
     int commentId = 5;
     Comments comment = new Comments();
     comment.description = "Teste";
     comment.id = 1;
     var actual = target.editCommentWithId(commentId, comment,"Normal Mode") as RedirectToRouteResult;
     Assert.AreEqual(actual.RouteValues["action"], "index");
     Assert.AreEqual(actual.RouteValues["controller"], "Maps");
     Assert.IsNotNull(actual);
 }
 public string sendLastSoundCommentFromIdLocationAndTypeOfComment(int idLocation,int idTypeOfComment, string code)
 {
     List<Comments> comments = new List<Comments>();
     Comments lastComment = new Comments();
     comments = commentServices.findCommentByIdLocation(idLocation);
     comments = (from comen in comments
                 where comen.typeOfCommentsId == idTypeOfComment
                 select comen).ToList();
     lastComment = comments.LastOrDefault();
     if (lastComment != null)
         return lastComment.sound;
     else
         return null;
 }
 public void showCommentsTest()
 {
     List<Locations> locations = new List<Locations>();
     Locations location = new Locations();
     Comments comment = new Comments();
     List<Comments> comments = new List<Comments>();
     comment.archiveDescription = "Teste";
     comment.description = "Teste";
     comment.id = 256;
     comment.isText = true;
     comment.locationsId = 20;
     comment.userId = 20;
     comment.sound = "1;0;1;0;1;1;1;1;1;0;0;0";
     comments.Add(comment);
     location.latitude = 10;
     location.longitude = 20;
     location.id = 20;
     locations.Add(location);
     iLocationServices.Setup(m => m.findLocationsAround(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<Double>())).Returns(locations);
     iCommentServices .Setup(m => m.findCommentByIdLocation(location.id)).Returns(comments);
     int idLocation = 20;
     LocationsController target = new LocationsController(iLocationServices.Object, iCommentServices.Object);
     ViewResult res;
     res = target.showComments(idLocation) as ViewResult;
     ViewDataDictionary tempData = res.ViewData as ViewDataDictionary;
     Assert.AreEqual(20, tempData["locationid"]);
     Assert.AreEqual(comments, tempData["comments"]);
     Assert.IsNotNull(res);
 }
        public ActionResult editCommentWithId(int commentId , Comments comment, string selectList)
        {
            SpeechSynthesizer speech = new SpeechSynthesizer("SmartAudioCityGuide", "Lz+vYpOFm6NTP83A9y0tPoX6ByJa06Q6yxHvoBsD0xo=");
            Comments newComments = commentsServices.findCommentByIdComment(commentId);
            Stream stream;
            byte[] bytes;
            newComments.isText = false;

            if (selectList == "--Select One--")
            {
                return RedirectToAction("index", "Maps");
            }

            else if (selectList == "Normal Mode")
            {
                comment.typeOfCommentsId = 1;
            }

            else if (selectList == "Exploration Mode")
            {
                comment.typeOfCommentsId = 2;
            }

            stream = speech.GetSpeakStream(comment.description);
            bytes = ReadFully(stream);
            newComments.sound = convertBytesToString(bytes);
            newComments.typeOfCommentsId = comment.typeOfCommentsId;

            commentsServices.updateCommentForId(commentId, comment);

            return RedirectToAction("index", "Maps");
        }
        public ActionResult editComment(int idComment)
        {
            Comments comment = new Comments();
            List<string> list = new List<string>();
            list.Add("Normal Mode");
            list.Add("Exploration Mode");
            comment = commentsServices.findCommentByIdComment(idComment);
            ViewData["commentId"] = idComment;
            ViewData["selectList"] = new SelectList(list);

            return View(comment);
        }
        public ActionResult addTextCommentWithLocation(Comments comment ,int locationId)
        {
            SpeechSynthesizer speech = new SpeechSynthesizer("SmartAudioCityGuide", "Lz+vYpOFm6NTP83A9y0tPoX6ByJa06Q6yxHvoBsD0xo=");
            Stream stream;
            byte[] bytes;
            comment.isText = false;
            comment.locationsId = locationId;

            stream = speech.GetSpeakStream(comment.description);
            bytes = ReadFully(stream);
            comment.sound = convertBytesToString(bytes);

            try
            {
                comment.userId = user.currentUser.id;
            }
            catch
            {

            }

            commentsServices.addComment(comment);

            return RedirectToAction("index", "Maps");
        }
 public void updateCommentForId(int idComment, Comments newComment)
 {
     Comments comment = new Comments();
     comment = db.comments.FirstOrDefault(m => m.id == idComment);
     comment.description = newComment.description;
     comment.sound = newComment.sound;
     comment.typeOfCommentsId = newComment.typeOfCommentsId;
     db.SaveChanges();
 }
 public void addComment(Comments comment)
 {
     db.comments.Add(comment);
     db.SaveChanges();
 }