Exemple #1
0
        public async Task AddError(Exception e)
        {
            try
            {
                var   model = new Error(e);
                Error Error = await _ctx.Errors.FirstOrDefaultAsync(x =>
                                                                    x.InnerMessage != model.InnerMessage &&
                                                                    x.Message != model.Message &&
                                                                    x.MethodName != model.MethodName);

                if (Error == null)
                {
                    await _ctx.AddAsync(model);
                }
                else
                {
                    Error.LastAccrued = DateTime.Now;
                    Error.Increase();
                    _ctx.Entry(Error).State = EntityState.Modified;
                }

                await _ctx.SaveChangesAsync();
            }
            catch (Exception) { }
        }
        public async Task <bool> Like(int id)
        {
            try
            {
                var data = await _ctx.Comments.FirstOrDefaultAsync(x => x.Id == id);

                if (data != null)
                {
                    data.Likes++;
                    _ctx.Entry(data).State = EntityState.Modified;
                    await _ctx.SaveChangesAsync();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }