public void AddAccaunt(Accaunt accaunt)
        {
            accaunt.id = nextAccauntId();

            enticontext.Accaunts.Add(accaunt);
            if (enticontext.SaveChanges() > 0)
            {
                string mess = $" " +
                              $"Добавлена счет : {accaunt.id} " +
                              $"открыт : {accaunt.OpenDate}," +
                              $"TypeId : " +
                              $"{accaunt.TypeId}," +
                              $"Rates : " +
                              $"{accaunt.Rates}," +
                              $"Capitalisation : " +
                              $"{accaunt.Capitalisation}," +
                              $"RatesTypeid : " +
                              $"{accaunt.RatesTypeid}," +
                              $"OwnerId :  " +
                              $"'{ accaunt.OwnerId}'";

                if (accaunt.EndDate != null)
                {
                    mess += $",EndDate :  " +
                            $"'{ accaunt.EndDate}'";
                }
                newLogMessage?.Invoke(mess);
            }
        }
 public void PushMoney(Accaunt accaunt, decimal money)
 {
     if (money > 0)
     {
         accaunt.Balans += money;
         if (enticontext.SaveChanges() > 0)
         {
             string mess = $"На счет {accaunt.id} зачислены {money}";
             MessageBox.Show(mess);
             newLogMessage?.Invoke(mess);
         }
     }
 }
        public void AddAccaunt(DateTime OpenDate, DateTime CloseDate, int TypeId, float Rates, int OwnerId, bool Capitalisation, int RatesTypeid)
        {
            Accaunt accaunt = new Accaunt
            {
                OpenDate       = OpenDate,
                EndDate        = CloseDate,
                TypeId         = TypeId,
                Rates          = Rates,
                RatesTypeid    = RatesTypeid,
                OwnerId        = OwnerId,
                Capitalisation = Capitalisation
            };

            AddAccaunt(accaunt);
        }
        public void PopMoney(Accaunt accaunt, decimal money)
        {
            string mess;

            if (accaunt.Balans >= money)
            {
                accaunt.Balans -= money;
                mess            = $"со счета {accaunt.id} списано: {money} ";
            }
            else
            {
                mess = $"На счету {accaunt.id} недостаточно средств. \n доступно : {accaunt.Balans}  запрошено: {money} ";
            }
            MessageBox.Show(mess);
            newLogMessage?.Invoke(mess);
            enticontext.SaveChanges();
        }
        public void DeleteAccaunt(AccauntForView accauntForView)
        {
            if (accauntForView.Balans > 0)
            {
                MessageBox.Show("Не возможно удалить счет при наличии остатка средств");
            }
            else
            {
                Accaunt acd  = enticontext.Accaunts.Where(a => a.id == accauntForView.id).FirstOrDefault();
                string  mess = $" " +
                               $"Удален счет : {acd.id} " +
                               $"открыт : {acd.OpenDate}," +
                               $"TypeId : " +
                               $"{acd.TypeId}," +
                               $"Rates : " +
                               $"{acd.Rates}," +
                               $"Capitalisation : " +
                               $"{acd.Capitalisation}," +
                               $"RatesTypeid : " +
                               $"{acd.RatesTypeid}," +
                               $"OwnerId :  " +
                               $"'{ acd.OwnerId}'";

                if (acd.EndDate != null)
                {
                    mess += $",EndDate :  " +
                            $"'{ acd.EndDate}'";
                    enticontext.Entry(acd).State = EntityState.Deleted;
                    if (enticontext.SaveChanges() > 0)
                    {
                        AccauntForViews.Remove(accauntForView);
                        newLogMessage?.Invoke(mess);
                    }
                    //enticontext.Clients.Remove(client);
                }
            }
        }