Exemplo n.º 1
0
        public EntityResult UpdateDistrict(DistrictViewModel districtModel)
        {
            if (districtModel == null)
            {
                throw new ArgumentNullException("districtModel");
            }

            try
            {
                var currentCity = _unitOfWork.DistrictRepository.GetByID(districtModel.DistrictId);
                if (currentCity == null)
                {
                    throw new ArgumentException("District is not exist.", "districtModel");
                }

                var district = districtModel.ToDistrict();
                _unitOfWork.DistrictRepository.Update(district);

                _unitOfWork.Save();
                return(EntityResult.Success);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, ex.Message);
                throw;
            }
        }
Exemplo n.º 2
0
 public EntityResult AddDistrict(DistrictViewModel districtModel)
 {
     if (districtModel == null)
     {
         throw new ArgumentNullException("districtModel");
     }
     try
     {
         var district = districtModel.ToDistrict();
         _unitOfWork.DistrictRepository.Add(district);
         _unitOfWork.Save();
         districtModel.DistrictId = district.Id;
         return(EntityResult.Success);
     }
     catch (Exception ex)
     {
         _logger.Error(ex, ex.Message);
         throw;
     }
 }