예제 #1
0
        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);
        }
예제 #2
0
        public async Task <Country> AddCountryAsync(string country)
        {
            var result = await _context.Countries.AddAsync(new Country { Name = country.ToLower() });

            await _context.SaveChangesAsync();

            return(result.Entity);
        }
예제 #3
0
        public async Task <MeetingPoint> InsertMeetingPointAsync(MeetingPoint meetingPoint)
        {
            meetingPoint.Id = 0;
            var result = await context.MeetingPoints.AddAsync(meetingPoint);

            await context.SaveChangesAsync();

            return(result.Entity);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public async Task <ClientAnswer> InsertInputAnswer(ClientAnswer answer)
        {
            answer.Id = 0;
            var updatedAnswer = await _context.ClientAnswers.AddAsync(answer);

            await _context.SaveChangesAsync();

            return(updatedAnswer.Entity);
        }
예제 #6
0
        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));
            }
        }
예제 #7
0
        public async Task <bool> DeleteAsync(Question question)
        {
            context.Questions.Remove(question);

            return(await context.SaveChangesAsync() > 0);
        }
예제 #8
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);
        }
예제 #9
0
        public async Task <bool> DeleteAsync(Category category)
        {
            context.Categories.Remove(category);

            return(await context.SaveChangesAsync() > 0);
        }
예제 #10
0
 public async Task <bool> DeleteAsync(Order order)
 {
     context.Orders.Remove(order);
     return(await context.SaveChangesAsync() > 0);
 }