示例#1
0
        public async Task <Tax> Add(Tax model)
        {
            var entity = _taxRepository.Add(model);
            await _taxRepository.SaveChangeAsync();

            return(model);
        }
示例#2
0
        public async Task <string> CreateTaxAsync()
        {
            string result = String.Empty;

            try
            {
                result = await _taxRepository.Add(this);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
示例#3
0
        public bool ScheduleTax(string municipalityName, Tax tax)
        {
            var municipality = _municipalityRepo.Get(municipalityName);

            if (municipality == null || municipality.IsTaxOverlapping(tax))
            {
                return(false);
            }

            tax.MunicipalityId = municipality.Id;
            _taxRepository.Add(tax);
            _taxRepository.Save();
            return(true);
        }
示例#4
0
        private void ImportMunicipalityTaxes(Municipality municipality, IEnumerable <Tax> taxes)
        {
            if (taxes == null)
            {
                return;
            }

            foreach (var tax in taxes)
            {
                if (municipality.IsTaxOverlapping(tax))
                {
                    continue;
                }

                tax.MunicipalityId = municipality.Id;
                _taxRepository.Add(tax);
            }
        }
 public bool Save(lmsTaxMaster entity)
 {
     try
     {
         if (entity.TAXID > 0)
         {
             taxRepository.Edit(entity);
         }
         else
         {
             taxRepository.Add(entity);
         }
         taxRepository.Save();
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#6
0
        public override string Import(string catalogId, string propertySetId, ImportItem[] systemValues, ImportItem[] customValues, IRepository repository)
        {
            var _error = string.Empty;

            _repository = (ITaxRepository)repository;

            var action = GetAction(systemValues.First(x => x.Name == "Action").Value);

            switch (action)
            {
            case ImportAction.Insert:
                var itemI = systemValues.FirstOrDefault(y => y.Name == "TaxId");
                if (itemI != null)
                {
                    var originalItem = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
                    if (originalItem.Count() == 0)
                    {
                        var name    = systemValues.FirstOrDefault(y => y.Name == "TaxName");
                        var type    = systemValues.FirstOrDefault(y => y.Name == "TaxType");
                        var addItem = new Tax {
                            TaxId = itemI.Value, Name = name.Value, TaxType = Int32.Parse(type.Value)
                        };
                        _repository.Add(addItem);
                        _repository.UnitOfWork.Commit();
                    }
                }

                var tax = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
                if (tax.Count() > 0)
                {
                    var t     = tax.First();
                    var value = InitializeItem(null, systemValues);
                    t.TaxValues.Add(value);
                }
                break;

            case ImportAction.InsertAndReplace:
                var itemR = systemValues.FirstOrDefault(y => y.Name == "TaxId");
                if (itemR != null)
                {
                    var originalItem = _repository.Taxes.Where(x => x.TaxId == itemR.Value).SingleOrDefault();
                    if (originalItem != null)
                    {
                        _repository.Remove(originalItem);
                    }
                }

                var replaceItem = InitializeItem(null, systemValues);
                _repository.Add(replaceItem);
                break;

            case ImportAction.Update:
                //var itemU = systemValues.FirstOrDefault(y => y.Name == "PriceId");
                //if (itemU != null)
                //{
                //	var origItem = _repository.Taxes.Where(x => x.TaxId == itemU.Value).SingleOrDefault();
                //	if (origItem != null && origItem is TaxValue)
                //	{
                //		InitializeItem((TaxValue)origItem, systemValues);
                //		_repository.Update(origItem);
                //	}
                //}
                break;

            case ImportAction.Delete:
                var itemD = systemValues.FirstOrDefault(y => y.Name == "TaxId");
                if (itemD != null)
                {
                    var deleteItem = _repository.Taxes.Where(x => x.TaxId == itemD.Value).SingleOrDefault();
                    if (deleteItem != null)
                    {
                        _repository.Remove(deleteItem);
                    }
                }
                break;
            }
            return(_error);
        }
示例#7
0
		public override string Import(string catalogId, string propertySetId, ImportItem[] systemValues, ImportItem[] customValues, IRepository repository)
		{
			var _error = string.Empty;
			_repository = (ITaxRepository)repository;

			var action = GetAction(systemValues.First(x => x.Name == "Action").Value);

			switch (action)
			{
				case ImportAction.Insert:
					var itemI = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemI != null)
					{
						var originalItem = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
						if (originalItem.Count() == 0)
						{
							var name = systemValues.FirstOrDefault(y => y.Name == "TaxName");
							var type = systemValues.FirstOrDefault(y => y.Name == "TaxType");
							var addItem = new Tax { TaxId = itemI.Value, Name = name.Value, TaxType = Int32.Parse(type.Value) };
							_repository.Add(addItem);
							_repository.UnitOfWork.Commit();
						}
					}
					
					var tax = _repository.Taxes.Where(x => x.TaxId == itemI.Value);
					if (tax.Count() > 0)
					{
						var t = tax.First();
						var value = InitializeItem(null, systemValues);
						t.TaxValues.Add(value);
					}
					break;
				case ImportAction.InsertAndReplace:
					var itemR = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemR != null)
					{
						var originalItem = _repository.Taxes.Where(x => x.TaxId == itemR.Value).SingleOrDefault();
						if (originalItem != null)
							_repository.Remove(originalItem);
					}

					var replaceItem = InitializeItem(null, systemValues);
					_repository.Add(replaceItem);
					break;
				case ImportAction.Update:
					//var itemU = systemValues.FirstOrDefault(y => y.Name == "PriceId");
					//if (itemU != null)
					//{
					//	var origItem = _repository.Taxes.Where(x => x.TaxId == itemU.Value).SingleOrDefault();
					//	if (origItem != null && origItem is TaxValue)
					//	{
					//		InitializeItem((TaxValue)origItem, systemValues);
					//		_repository.Update(origItem);
					//	}
					//}
					break;
				case ImportAction.Delete:
					var itemD = systemValues.FirstOrDefault(y => y.Name == "TaxId");
					if (itemD != null)
					{
						var deleteItem = _repository.Taxes.Where(x => x.TaxId == itemD.Value).SingleOrDefault();
						if (deleteItem != null)
							_repository.Remove(deleteItem);
					}
					break;
			}
			return _error;
		}