public EntityResult <BLL_UserView> AddUserView(BLL_UserView bLL_UserView) { try { validateParams(bLL_UserView); if (bLL_UserView.CustomView ?? true) { bLL_UserView.SortOrder = _UserViewRepository.GetNextSortOrder(UserIdentity.UserId, bLL_UserView.ScreenName); } grs_TblUserview tbUserView = new grs_TblUserview(); AssignDefaults(tbUserView, bLL_UserView); var userview = _UserViewRepository.Get(d => d.Userid == tbUserView.Userid && d.Screenname == tbUserView.Screenname && d.Viewname == tbUserView.Viewname); if (!(userview == null)) { throw new IllegalArgumentAPIException(string.Format("User view already exists with combination of screen '{0}' and view '{1}'", tbUserView.Screenname, tbUserView.Viewname)); } if (bLL_UserView.Default ?? false) //reset existing then update default column { _UserViewRepository.FindBy(d => d.Userid == UserIdentity.UserId && d.Screenname == bLL_UserView.ScreenName && d.Default).ToList().ForEach(v => v.Default = false); tbUserView.Default = true; } _UserViewRepository.Add(tbUserView); _UserViewRepository.Save(tbUserView); return(new EntityResult <BLL_UserView>(_UserViewTransformationManager.Transform(_UserViewRepository.Get(d => d.ViewId == tbUserView.ViewId)))); } catch (Exception ex) { throw ex; } }