Beispiel #1
0
        public ConnectTariffModel(TariffPlanModel tariffPlan, ConnectTariff connectTariff)
        {
            name = tariffPlan.name;

            dateConnectTariffBegin = connectTariff.dateConnectTariffBegin;
            dateConnectTariffEnd   = connectTariff.dateConnectTariffEnd;
            idClient = connectTariff.idClient;
            if (dateConnectTariffEnd == null)
            {
                DateTime dateNow = DateTime.Now;
                connectedMonth = 0;
                while (Convert.ToDateTime(dateConnectTariffBegin).AddMonths(1) < dateNow)
                {
                    connectedMonth++;
                }
            }
            else
            {
                connectedMonth = 0;
                while (Convert.ToDateTime(dateConnectTariffBegin).AddMonths(1) < dateConnectTariffEnd)
                {
                    connectedMonth++;
                }
            }
            cost = tariffPlan.subscriptionFee * connectedMonth + tariffPlan.costChangeTar;
        }
Beispiel #2
0
        public CallModel(Call call)
        {
            TariffPlanModel activeTariff = db.GetActiveTariff(Convert.ToInt32(call.idClient));
            ClientModel     client       = db.GetItemClient(Convert.ToInt32(call.idClient));

            dateCall      = call.dateCall;
            dateCallShort = Convert.ToDateTime(dateCall).ToString("d");
            timeTalk      = call.timeTalk;
            numberWasCall = call.numberWasCall;
            callType      = call.callType;
            switch (callType)
            {
            case 1:
                callTypeString = "Городской";
                break;

            case 2:
                callTypeString = "Междугородний";
                break;

            case 3:
                callTypeString = "В другую страну";
                break;
            }
            costCall     = Convert.ToDouble(call.costCall);
            incomingCall = call.incomingCall;
            switch (incomingCall)
            {
            case true:
                incomingCallText = "Исходящий";
                break;

            case false:
                incomingCallText = "Входящий";
                break;
            }

            /*            if (client.freeMin == 0)
             *          {
             *              switch (callType)
             *              {
             *                  case 1:
             *                      costCall = Convert.ToDouble(-(timeTalk * activeTariff.costOneMinCallCity));
             *                      db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32( costCall));
             *                      break;
             *                  case 2:
             *                      costCall = Convert.ToDouble(-(timeTalk * activeTariff.costOneMinCallOutCity));
             *                      db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32(costCall));
             *                      break;
             *                  case 3:
             *                      costCall = Convert.ToDouble(-(timeTalk * activeTariff.CostOneMinCallInternation));
             *                      db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32(costCall));
             *                      break;
             *              }
             *          }else
             *              if (client.freeMin > 0)
             *          {
             *              var timeFree = client.freeMin - timeTalk;
             *              if (timeFree >= 0)
             *              {
             *                  costCall = 0;
             *                  db.UpdateFreeMinForClient(Convert.ToInt32(call.idClient), Convert.ToInt32(timeFree));
             *              }else
             *                  if (timeFree < 0)
             *              {
             *                  db.UpdateFreeMinForClient(Convert.ToInt32(call.idClient), Convert.ToInt32(client.freeMin - client.freeMin));
             *                  switch (callType)
             *                  {
             *                      case 1:
             *                          costCall = Convert.ToDouble(timeFree * activeTariff.costOneMinCallCity);
             *                          db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32(costCall));
             *                          break;
             *                      case 2:
             *                          costCall = Convert.ToDouble(timeFree * activeTariff.costOneMinCallOutCity);
             *                          db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32(costCall));
             *                          break;
             *                      case 3:
             *                          costCall = Convert.ToDouble(timeFree * activeTariff.CostOneMinCallInternation);
             *                          db.UpdateBalanceClient(Convert.ToInt32(call.idClient), Convert.ToInt32(costCall));
             *                          break;
             *                  }
             *              }
             *          }*/
            idClient = call.idClient;
            id       = call.id;
        }