// MapSiteVMtoDB maps the site view model properties to the site database properties.
func MapSiteVMtoDB(siteVM *SitesEditViewModel, site *database.Site) error {
	site.SiteID = siteVM.SiteID
	site.Name = siteVM.Name
	site.IsActive = siteVM.IsActive
	site.URL = strings.TrimSpace(siteVM.URL)
	site.ContentExpected = strings.TrimSpace(siteVM.ContentExpected)
	site.ContentUnexpected = strings.TrimSpace(siteVM.ContentUnexpected)
	// Conversion on these two is necessary because they are a string in the
	// view model to allow the validation to work
	pingInterval, err := strconv.Atoi(siteVM.PingIntervalSeconds)
	if err != nil {
		return err
	}
	site.PingIntervalSeconds = pingInterval
	timeout, err := strconv.Atoi(siteVM.TimeoutSeconds)
	if err != nil {
		return err
	}
	site.TimeoutSeconds = timeout

	return nil
}