protected override void RowConverter(ChargeMethod item, DataRow row)
 {
     item.BILLING_PRECISION     = CastDbValueRow(row, "BILLING_PRECISION", true, "Int32");
     item.CHAR_COMP_METHOD      = CastDbValueRow(row, "CHAR_COMP_METHOD");
     item.CHARS_PER_LINE        = CastDbValueRow(row, "CHARS_PER_LINE", true, "Int32");
     item.DESCR                 = CastDbValueRow(row, "DESCR");
     item.GP_ITEM_DESCR         = CastDbValueRow(row, "GP_ITEM_DESCR");
     item.INVOICE_COLUMN_HEADER = CastDbValueRow(row, "INVOICE_COLUMN_HEADER");
     item.ROUNDING_STYLE        = CastDbValueRow(row, "ROUNDING_STYLE", true, "Bool");
 }
Example #2
0
        public IHttpActionResult CreateNewChargeMethod([FromUri] int templateId, [FromUri] int from, [FromUri] int to, [FromUri] double fee)
        {
            int duration           = to - from + 1;
            var chargeTemplateInDb = _context.ChargeTemplates.Find(templateId);

            //try
            //{
            //    if (period.Split('-').Count() > 1)
            //    {
            //        weeks = int.Parse(period.Split('-')[1]) - int.Parse(period.Split('-')[0]);

            //    }
            //    else
            //    {
            //        weeks = int.Parse(period);
            //    }
            //}
            //catch(Exception e)
            //{
            //    throw new Exception("Period is invalid.");
            //}

            var newMethod = new ChargeMethod
            {
                Fee            = fee,
                From           = from,
                To             = to,
                Duration       = duration,
                ChargeTemplate = chargeTemplateInDb,
                TimeUnit       = chargeTemplateInDb.TimeUnit,
                Currency       = chargeTemplateInDb.Currency
            };

            _context.ChargeMethods.Add(newMethod);
            _context.SaveChanges();

            var sample = _context.ChargeMethods.OrderByDescending(x => x.Id).First();

            return(Created(Request.RequestUri + "/" + sample.Id, Mapper.Map <ChargeMethod, ChargeMethodDto>(sample)));
        }
 public override void Update(ChargeMethod entity)
 {
     throw new NotImplementedException();
 }
 public override ChargeMethod Get(ChargeMethod entity)
 {
     throw new NotImplementedException();
 }