示例#1
0
        /// <summary>
        /// It generates a charge on an bill (which if it does not exist will be created for the current month)
        /// </summary>
        /// <param name="user">User to be charged</param>
        /// <param name="charge">Charge with the amount</param>
        /// <returns></returns>
        public Charge Add(int idUser, Charge charge)
        {
            // Get the Current bill for the user
            var billComponent = new BillComponent();
            var bill          = billComponent.GetBillByUserAndMonth(idUser, DateTime.Now);

            if (bill == null)
            {
                bill = new Bill()
                {
                    IdUser = idUser
                };
                bill = billComponent.Add(idUser, bill);
            }

            // Add a charge for that bill
            var chargeResult = default(Charge);
            var chargeDAC    = new ChargeDAC();

            chargeResult = chargeDAC.Create(charge);

            // Add a Bill Charge with te information
            var billChargeComponent = new BillChargeComponent();
            var billCharge          = billChargeComponent.Add(bill, chargeResult);

            return(chargeResult);
        }
示例#2
0
        /// <summary>
        /// Obains the charge that match with the id
        /// </summary>
        /// <param name="id">Charge id to be searched</param>
        /// <returns></returns>
        public Charge GetById(int id)
        {
            Charge result = default(Charge);

            var chargeDAC = new ChargeDAC();

            result = chargeDAC.ReadBy(id);
            return(result);
        }
示例#3
0
        public IList <Charge> GetTop1000()
        {
            var chargeDAC = new ChargeDAC();

            return(chargeDAC.Read());
        }
示例#4
0
        /// <summary>
        /// Deletes the charge that match with the id
        /// </summary>
        /// <param name="Id">Charge id to be deleted</param>
        public void Delete(int Id)
        {
            var chargeDAC = new ChargeDAC();

            chargeDAC.Delete(Id);
        }
示例#5
0
        /// <summary>
        /// Edit the charge that match with the current id
        /// </summary>
        /// <param name="charge">Data to be edited</param>
        public void Edit(Charge charge)
        {
            var chargeDAC = new ChargeDAC();

            chargeDAC.Update(charge);
        }