Beispiel #1
0
        public async Task <DtoComment[]> GetComments(string login, string password)
        {
            var ret = new ObservableCollection <DtoComment>();

            using (var data = Context)
                foreach (var item in await(from item in data.Comments where item.Users.login == login && item.Users.password == password select item).ToListAsync())
                {
                    ret.Add(CommentConverter.DataAccsessToDto(item));
                }
            return(ret.ToArray());
        }
Beispiel #2
0
        public async Task <DtoComment[]> GetAllComments()
        {
            var ret = new ObservableCollection <DtoComment>();

            using (var data = Context)
                foreach (var item in await(from item in data.Comments select item).ToListAsync())
                {
                    ret.Add(CommentConverter.DataAccsessToDto(item));
                }
            return(ret.ToArray());
        }
Beispiel #3
0
        public async Task <DtoComment> GetComment(int commentId)
        {
            try
            {
                using (var data = Context)
                {
                    var a = data.Comments;
                    var b = a.Where(item => item.userId == commentId);
                    var c = await b.FirstOrDefaultAsync();

                    return(CommentConverter.DataAccsessToDto(c));
                }
            }
            catch (Exception ex)
            {
                return(new DtoComment {
                    Id = -1
                });
            }
        }
Beispiel #4
0
        public async Task <DtoComment> GetLastComment(string placeId)
        {
            using (var data = Context)
            {
                var places = data.Comments.Where(c => c.placeId == placeId);
                if (places.Any())
                {
                    int maxId   = places.Max(com => com.id);
                    var comment = await data.Comments.SingleAsync(c => c.id == maxId);

                    DateTime date = DateTime.ParseExact(comment.date, "g", CultureInfo.InvariantCulture);
                    if (GetDateTimeNow().AddHours(-12) < date)
                    {
                        return(CommentConverter.DataAccsessToDto(comment));
                    }
                    return(null);
                }
                return(null);
            }
        }