public static BOCulture GetDefault()
        {
            SqlConnection con = new SqlConnection(GetConnectionString());
            con.Open();
            try
            {
                SqlCommand cmd = new SqlCommand("P_Culture_GetDefault", con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleResult);
                try
                {
                    if (rdr.Read())
                    {
                        BOCulture BusinessObject = new BOCulture(rdr);
                        return BusinessObject;
                    }
                    else
                    {
                        //Create Key if it does not exist
                        BOCulture BusinessObject = new BOCulture();
                        CultureInfo cultureInfo = CultureInfo.GetCultureInfo("en-US");
                        BusinessObject.Name = cultureInfo.Name;
                        BusinessObject.DisplayName = cultureInfo.DisplayName;
                        BusinessObject.EnglishName = cultureInfo.EnglishName;
                        BusinessObject.Available = true;
                        BusinessObject.Default = true;
                        BusinessObject.Save();
                        return BusinessObject;
                    }

                }
                finally
                {
                    rdr.Close();
                }
            }
            finally
            {
                con.Close();
            }
        }
        public ActionResult Create(CultureViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (_cultureService.GetCultureByName(model.Name) == null)
                {
                    var culture = new BOCulture();
                    bool isDefaultExist = _cultureService.GetAll().Any(c => c.Default);

                    Mapper.Map<CultureViewModel, BOCulture>(model, culture);

                    try
                    {
                        var info = new CultureInfo(model.Name);
                        culture.DisplayName = info.DisplayName;
                        culture.EnglishName = info.EnglishName;
                        culture.Available = true;
                        culture.Default = !isDefaultExist;
                    }
                    catch (CultureNotFoundException)
                    {
                        ModelState.AddModelError("Message", "Culture code is not valid.");
                        return View(model);
                    }

                    _cultureService.Save(culture);

                    if (model.PreviousUrl != null)
                        return Redirect(model.PreviousUrl.AbsoluteUri);

                    return RedirectToAction("Index");
                }

                ModelState.AddModelError("Message", "Culture with this name already exists.");
            }

            return View(model);
        }
 public void Save(BOCulture culture)
 {
     _cultureRepository.Save(culture);
 }
 public BOCultureComparer(BOCulture.Columns column, BOCulture.SortDirections direction)
 {
     _column = column;
     _direction = direction;
 }