public static CountryResponse AddCountry(CountryRequest request) { var response = new CountryResponse(); var countryRepository = new CountryRepository(); try { var newCountry = new country { country_name = request.CountryName, created_date = DateTime.Now, modified_date = DateTime.Now, modified_by = request.ModifiedBy }; countryRepository.Add(newCountry); countryRepository.SaveChanges(); } catch (InvalidOperationException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (ArgumentNullException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (NullReferenceException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (OptimisticConcurrencyException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } catch (UpdateException exc) { log.Error(exc); response.Message = exc.Message; response.Acknowledge = AcknowledgeType.FAILURE; } finally { countryRepository.Dispose(); } return response; }
/// <summary> /// Create a new country object. /// </summary> /// <param name="country_id">Initial value of the country_id property.</param> public static country Createcountry(global::System.Int32 country_id) { country country = new country(); country.country_id = country_id; return country; }
/// <summary> /// Deprecated Method for adding a new object to the countries EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTocountries(country country) { base.AddObject("countries", country); }