public string CreateInvoice(InvoicePostDto newInvoice)
        {
            var     userSrv = new UserService(bmsData);
            Invoice invoice;

            invoice = new Invoice()
            {
                InvoiceNum    = int.Parse(newInvoice.InvoiceNum),
                ClientId      = (int)newInvoice.ClientId,
                SupplierId    = (int)newInvoice.SupplierId,
                ProjectId     = newInvoice.ProjectId,
                Date          = newInvoice.Date,
                Town          = newInvoice.Town,
                Text          = newInvoice.Text,
                BankRequisits = newInvoice.BankRequisits,
                Price         = newInvoice.Price,
                Vat           = newInvoice.Vat,
                Total         = newInvoice.Total
            };
            bmsData.Invoices.Add(invoice);

            bmsData.SaveChanges();

            return($"Invoice with number {newInvoice.InvoiceNum} from date {newInvoice.Date.ToShortDateString()} successfully created!");
        }
        public string CreateInquiry(InquiryPostDto newInquiry)
        {
            var userSrv = new UserService(bmsData);
            var inquiry = new Inquiry()
            {
                CreatorId    = newInquiry.CreatorId,
                ContragentId = newInquiry.ClientId,
                Description  = newInquiry.Description,
                Date         = newInquiry.Date
            };

            bmsData.Inquiries.Add(inquiry);
            bmsData.SaveChanges();

            return($"Inquiry {newInquiry.Description} from date {newInquiry.Date.ToShortDateString()} successfully created!");
        }
        public string CreateContragent(ContragentPostDto newContragent)
        {
            var userSrv    = new UserService(bmsData);
            var contragent = new Contragent()
            {
                Name = newContragent.Name,
                PersonalIndentityNumber = newContragent.PersonalIndentityNumber,
                PersonalVatNumber       = newContragent.PersonalVatNumber,
                Town             = newContragent.Town,
                Address          = newContragent.Address,
                Telephone        = newContragent.Telephone,
                Email            = newContragent.Email,
                PersonForContact = newContragent.PersonForContact,
                BankDetails      = newContragent.BankDetails,
                Description      = newContragent.Description
            };

            bmsData.Contragents.Add(contragent);
            bmsData.SaveChanges();

            return($"Contragent {newContragent.Name} successfully created!");
        }
        public string CreateUser(string username, string password, ClearenceType userType)
        {
            var existingUser = this.GetUserByUsername(username);

            if (existingUser != null)
            {
                throw new ArgumentException("Username already exists!");
            }

            var hashedPass = HashToSha1(password);

            var newUser = new User
            {
                Username = username,
                Password = hashedPass,
                Type     = userType
            };

            bmsData.Users.Add(newUser);
            bmsData.SaveChanges();

            return("User has been successfully registered!");
        }