/// <summary>
        /// Saves the town.
        /// </summary>
        /// <param name="town">The town.</param>
        /// <returns></returns>
        public async Task <int> SaveTown(EntityTown town)
        {
            town.Id = UtilsService.GenerateId(town.Id);

            return(await Util.TryAsync(() => GetConnection().InsertOrReplaceAsync(town),
                                       failureMessage : "DataContext {SaveTown} failed to load EntityTown"));
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        internal static ModelTown ToModel(this EntityTown entity)
        {
            var model = new ModelTown();

            model.Id         = entity.Id;
            model.ProvinceId = entity.ProvinceId;
            model.Name       = entity.Name;

            return(model);
        }