public async Task <RequestStatus> AddMember(Members member) { try { var model = await _ctx.Members.FirstOrDefaultAsync(x => x.Name == member.Name && x.LastName == member.LastName); if (model == null) { await _ctx.Members.AddAsync(member); await _ctx.SaveChangesAsync(); return(new RequestStatus(true)); } else { return(new RequestStatus("Alredy inserted", false)); } } catch (Exception e) { await AddError(e); return(new RequestStatus(e.InnerException.Message, false)); } }
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); } }