Exemplo n.º 1
0
        public void Create(ServiceChargeModel model)
        {
            try
            {
                if (_serviceChargeRepository.NameExist(model))
                {
                    throw new Exception("Service Charge Already Exists!");
                }


                //var serviceCharge = new ServiceCharge()
                //{
                //    Name = model.Name,
                //    Amount = model.Amount,
                //    IsCompulsory = model.IsCompulsory,
                //    TotalAmountPaid = 0,
                //    DateCreated = model.DateCreated,
                //    DueDay = model.DueDay,
                //    DueMonth = model.DueMonth
                //};
                var serviceCharge = Mapper.Map <ServiceChargeModel, ServiceCharge>(model);
                serviceCharge.DateCreated = DateTime.Now;
                if (model.BuildingModelIds.Any())
                {
                    serviceCharge.BuildingIds = string.Join(",", model.BuildingModelIds);
                }
                _serviceChargeRepository.Insert(serviceCharge);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void Create(ServiceChargeModel model)
        {
            try
            {
                if (_serviceChargeRepository.NameExist(model))
                {
                    throw new ArgumentException("Service CHarge Already Exists!");
                }


                var serviceCharge = new ServiceCharge()
                {
                    Name            = model.Name,
                    Amount          = model.Amount,
                    IsCompulsory    = model.IsCompulsory,
                    TotalAmountPaid = 0,
                    DateCreated     = model.DateCreated,
                    DueDay          = model.DueDay,
                    DueMonth        = model.DueMonth
                };
                if (model.BuildingModelIds.Any())
                {
                    serviceCharge.BuildingIds = string.Join(",", model.BuildingModelIds);
                }
                _serviceChargeRepository.Insert(serviceCharge);
            }
            catch (Exception)
            {
                throw;
            }
        }