public async Task <IActionResult> Login(string Email, string Password)
        {
            bool success = false;
            User user    = new User();

            try
            {
                user = await _user.GetUserAsync(
                    email : Email,
                    password : Password
                    );

                success = user != null;
            }
            catch { }
            if (success)
            {
                await _journal.AddAsync(
                    new UserJournal()
                {
                    Message    = $"Вход пользователя",
                    CreateDate = DateTime.Now,
                    UserId     = user.Id
                });

                return(Ok(user));
            }
            else if (user == null)
            {
                return(BadRequest(new { message = "Пользователь не найден" }));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> UpdateUser([FromBody] User user)
        {
            bool      bSuccess  = false;
            ErrorCode errorCode = ErrorCode.NO_ERROR;

            try
            {
                errorCode = await _user.UpdateAsync(user);

                bSuccess = errorCode == ErrorCode.NO_ERROR;
            }
            catch { }
            if (bSuccess)
            {
                await _journal.AddAsync(
                    new UserJournal()
                {
                    Message    = $"Изменение профиля",
                    CreateDate = DateTime.Now,
                    UserId     = user.Id
                });

                return(Ok(user));
            }
            else
            {
                switch (errorCode)
                {
                case ErrorCode.SAVE_ERROR:
                    return(BadRequest(new { message = "Ошибка при сохранении" }));

                case ErrorCode.USER_NOT_FOUND:
                    return(BadRequest(new { message = "Пользователь не найден" }));

                case ErrorCode.EMAIL_EXIST:
                    return(BadRequest(new { message = "Такой Email уже существует" }));

                default:
                    return(BadRequest());
                }
            }
        }
        public async Task <IActionResult> GetDocFile(int userId, int docId, string fileName)
        {
            if (fileName == "")
            {
                return(BadRequest());
            }

            var fileExtension = Path.GetExtension(fileName);
            var fileProvider  = new FileExtensionContentTypeProvider();

            if (!fileProvider.TryGetContentType(fileExtension, out string contentType))
            {
                return(BadRequest($"Unable to find Content Type for file name with extension={fileExtension}."));
            }
            var memory = new MemoryStream();

            using (var stream = new FileStream(GetPathAndFilename(fileName, userId, docId), FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }
            memory.Position = 0;
            await _docJournal.AddAsync(new DocJournal()
            {
                Message    = $"Скачивание документа {fileName}",
                CreateDate = DateTime.Now,
                EventType  = 2,
                DocId      = docId,
                UserId     = userId
            });

            await _journal.AddAsync(new UserJournal()
            {
                Message = $"Скачивание документа {fileName}", CreateDate = DateTime.Now, UserId = userId
            });

            return(File(memory, contentType));
        }