Exemplo n.º 1
0
        public bool SetPreferencesV2(string RegistrationKey, webforms_preference prefObj)
        {
            long DentalOfficeID = util.GetDentalOfficeID(RegistrationKey);

            try {
                ODWebServiceEntities db = new ODWebServiceEntities();
                if (DentalOfficeID == 0)
                {
                }
                var wspObj = db.webforms_preference.Where(wsp => wsp.DentalOfficeID == DentalOfficeID);
                //update preference
                if (wspObj.Count() > 0)
                {
                    wspObj.First().ColorBorder = prefObj.ColorBorder;
                    wspObj.First().CultureName = prefObj.CultureName;
                }
                // if there is no entry for that dental office make a new entry.
                if (wspObj.Count() == 0)
                {
                    prefObj.DentalOfficeID = DentalOfficeID;
                    db.AddTowebforms_preference(prefObj);
                }
                db.SaveChanges();
                Logger.Information("Preferences saved IpAddress=" + HttpContext.Current.Request.UserHostAddress + " DentalOfficeID=" + DentalOfficeID);
            }
            catch (Exception ex) {
                Logger.LogError("IpAddress=" + HttpContext.Current.Request.UserHostAddress + " DentalOfficeID=" + DentalOfficeID, ex);
                return(false);
            }
            return(true);
        }