public async Task <int> WriteDialogAsync(UserSpecialistMessage uSMessage, Message message = null) { if (uSMessage.Id != 0) { if (uSMessage.LogFilePath != null) { await using FileStream fs = new FileStream(uSMessage.LogFilePath, FileMode.Append, FileAccess.Write); await using StreamWriter sw = new StreamWriter(fs); if (message != null) { await sw.WriteLineAsync(JsonSerializer.Serialize(message)); } return(0); } } { var path = Environment.CurrentDirectory + @"\MessagesLog\" + $"{Guid.NewGuid().ToString()}.txt"; uSMessage.LogFilePath = path; await _context.UserSpecialistMessages.AddAsync(uSMessage); await _context.SaveChangesAsync(); await using FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write); await using StreamWriter sw = new StreamWriter(fs); if (message != null) { await sw.WriteLineAsync(JsonSerializer.Serialize(message)); } } return(uSMessage.Id); }
public async Task <Country> AddCountryAsync(string country) { var result = await _context.Countries.AddAsync(new Country { Name = country.ToLower() }); await _context.SaveChangesAsync(); return(result.Entity); }
public async Task <MeetingPoint> InsertMeetingPointAsync(MeetingPoint meetingPoint) { meetingPoint.Id = 0; var result = await context.MeetingPoints.AddAsync(meetingPoint); await context.SaveChangesAsync(); return(result.Entity); }
public async Task <Client> InsertAsync(Client client) { client.Id = 0; client.LastVisit = DateTime.Now; var result = await context.Clients.AddAsync(client); await context.SaveChangesAsync(); return(result.Entity); }
public async Task <ClientAnswer> InsertInputAnswer(ClientAnswer answer) { answer.Id = 0; var updatedAnswer = await _context.ClientAnswers.AddAsync(answer); await _context.SaveChangesAsync(); return(updatedAnswer.Entity); }
public async Task WriteCommentAsync(ReviewComment reviewComment, Message message) { if (reviewComment.Id != 0) { if (reviewComment.LogFilePath != null) { await using FileStream fs = new FileStream(reviewComment.LogFilePath, FileMode.Append, FileAccess.Write); await using StreamWriter sw = new StreamWriter(fs); await sw.WriteLineAsync(JsonSerializer.Serialize(message)); return; } } { var path = Environment.CurrentDirectory + @"\CommentsLog\" + $"{new Guid()}.txt"; reviewComment.LogFilePath = path; await _context.ReviewComments.AddAsync(reviewComment); await _context.SaveChangesAsync(); await using FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write); await using StreamWriter sw = new StreamWriter(fs); await sw.WriteLineAsync(JsonSerializer.Serialize(message)); } }
public async Task <bool> DeleteAsync(Question question) { context.Questions.Remove(question); return(await context.SaveChangesAsync() > 0); }
public async Task <Specialist> InsertAsync(Specialist specialist) { specialist.Id = 0; specialist.LastVisit = DateTime.Now; var spec = await context.Specialists.AddAsync(specialist); await context.SaveChangesAsync(); return(spec.Entity); }
public async Task <bool> DeleteAsync(Category category) { context.Categories.Remove(category); return(await context.SaveChangesAsync() > 0); }
public async Task <bool> DeleteAsync(Order order) { context.Orders.Remove(order); return(await context.SaveChangesAsync() > 0); }