/// <summary>
 /// Convert RaceDefinition Entity  into RaceDefinition Object
 /// </summary>
 ///<param name="model">RaceDefinitionViewModel</param>
 ///<param name="RaceDefinitionEntity">DataAccess.RaceDefinition</param>
 ///<returns>RaceDefinitionViewModel</returns>
 public static RaceDefinitionViewModel ToViewModel(
     this DataAccess.RaceDefinition entity,
     RaceDefinitionViewModel model)
 {
     model.Id          = entity.Id;
     model.Name        = entity.Name;
     model.CountryId   = entity.Province.CountryId;
     model.ProvinceId  = entity.ProvinceId;
     model.DiscplineId = entity.DiscplineId;
     model.RaceTypeId  = entity.RaceTypeId;
     model.IsActive    = entity.IsActive;
     model.RaceType    = entity.RaceType.Name;
     model.Province    = entity.Province.Name;
     model.Country     = entity.Province.Country.Name;
     return(model);
 }
        /// <summary>
        /// Convert RaceDefinition Object into RaceDefinition Entity
        /// </summary>
        ///<param name="model">RaceDefinition</param>
        ///<param name="RaceDefinitionEntity">DataAccess.RaceDefinition</param>
        ///<returns>DataAccess.RaceDefinition</returns>
        public static DataAccess.RaceDefinition ToEntity(this RaceDefinitionViewModel model,
                                                         DataAccess.RaceDefinition entity)
        {
            if (entity.Id == 0)
            {
                entity.CreatedUserId = model.SessionUserId;
                entity.IsActive      = model.IsActive;
            }
            else
            {
                entity.UpdatedUserId    = model.SessionUserId;
                entity.UpdatedTimestamp = DateTime.Now;
            }
            entity.Name        = model.Name;
            entity.ProvinceId  = model.ProvinceId;
            entity.DiscplineId = model.DiscplineId;
            entity.RaceTypeId  = model.RaceTypeId;

            return(entity);
        }