public async Task <long> Create(DocumentsCreateRequest request) { var user = new User() { }; var document = new Document() { UserID = request.UserID, FacultyOfDocumentID = request.FalcultyOfDocumentID, MagazineID = request.MagazineID, Caption = "Document file", CreateOn = DateTime.Now.Date, }; if (request.DocumentFile != null) { user.Documents = new List <Document>() { new Document() { Caption = "Document file", CreateOn = DateTime.Now.Date, FileSize = request.DocumentFile.Length, DocumentPath = await this.SaveFile(request.DocumentFile), } }; } if (request.FalcultyOfDocumentID == 1) { SystemConstants.SendMail("*****@*****.**"); } _context.Documents.Add(document); await _context.SaveChangesAsync(); return(document.ID); }