Esempio n. 1
0
 public HttpResponseMessage UpdateCountries(CountrySaveRequest request)
 {
     try
     {
         var result = _adminServices.UpdateCountrys(request);
         if (result != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, result));
         }
         return(Request.CreateResponse(HttpStatusCode.NotModified, false));
     }
     catch (Exception exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message));
     }
 }
Esempio n. 2
0
 public int?UpdateCountrys(CountrySaveRequest request)
 {
     if (request.Id != null)
     {
         var countries = _countryRepository.GetSingleNoneDeleted(x => x.Id == request.Id);
         //update
         if (countries != null)
         {
             countries.CountryName  = request.CountryName;
             countries.ModifiedDate = Constants.GetDateNow();
             countries.ModifiedBy   = Constants.GetUserId();
             _countryRepository.Update(countries);
             _countryRepository.Commit();
         }
         if (countries != null)
         {
             return(countries.Id);
         }
     }
     else
     {
         //add new
         var newCountry = new Country
         {
             CountryName  = request.CountryName,
             CreatedBy    = Constants.GetUserId(),
             ModifiedBy   = Constants.GetUserId(),
             CreatedDate  = Constants.GetDateNow(),
             ModifiedDate = Constants.GetDateNow()
         };
         _countryRepository.Add(newCountry);
         _countryRepository.Commit();
         return(newCountry.Id);
     }
     return(null);
 }