예제 #1
0
        public IActionResult UpadteCountry([FromBody] CountryInsertDto input, [FromQuery] long countryId)
        {
            try
            {
                var loc = _repository.Location.FindByCondition(c => c.Id == countryId).FirstOrDefault();
                if (loc == null)
                {
                    throw new BusinessException(XError.GetDataErrors.NotFound());
                }

                loc.Name         = input.Name;
                loc.EnName       = input.EnName;
                loc.Pid          = null;
                loc.LocationCode = input.LocationCode;
                loc.PostCode     = input.PostCode;
                loc.MuserId      = ClaimPrincipalFactory.GetUserId(User);
                loc.Mdate        = DateTime.Now.Ticks;

                _repository.Location.Update(loc);
                _logger.LogData(MethodBase.GetCurrentMethod(), loc.Id, null, input, countryId);
                return(Ok(loc.Id));
            }
            catch (Exception e)
            {
                _logger.LogError(e, MethodBase.GetCurrentMethod(), input, countryId);
                return(BadRequest(e.Message));
            }
        }
예제 #2
0
        public CountryDto Insert(CountryInsertDto dto)
        {
            CountryDto countryDto = null;

            try
            {
                var country = Mapper.Map <CountryInsertDto, Country>(dto);
                country.CreatedBy = _appSession.GetUserName();
                country.IsEnabled = true;
                _unitOfWork.CreateTransaction();

                _unitOfWork.GenericRepository <Country>().Insert(country);
                _unitOfWork.Save();

                _unitOfWork.Commit();

                countryDto = Mapper.Map <Country, CountryDto>(country);
            }
            catch (Exception ex)
            {
                Tracing.SaveException(ex);
                _unitOfWork.Rollback();
            }
            return(countryDto);
        }
예제 #3
0
 public IActionResult InsertCountry(CountryInsertDto input)
 {
     try
     {
         var loc = new Location
         {
             Name         = input.Name,
             EnName       = input.EnName,
             Pid          = null,
             LocationCode = input.LocationCode,
             PostCode     = input.PostCode,
             CuserId      = ClaimPrincipalFactory.GetUserId(User),
             Cdate        = DateTime.Now.Ticks
         };
         _repository.Location.Create(loc);
         _logger.LogData(MethodBase.GetCurrentMethod(), loc.Id, null, input);
         return(Ok(loc.Id));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod(), input);
         return(BadRequest(e.Message));
     }
 }