/// <summary>
        /// This method will validate a property value in a <see cref="BaseModel"/> object asyncronously.
        /// </summary>
        /// <param name="model">A <see cref="BaseModel"/> to validate.</param>
        /// <param name="value">The value to validate.</param>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <param name="callback">A <see cref="AsyncCallback"/> that will be called when the operation completes.</param>
        /// <param name="state">A user defined object providing state to the asycronous operation.</param>
        /// <returns>A <see cref="IAsyncResult"/> object representing the asyncronous operation.</returns>
        /// <exception cref="InvalidOperationException">If the engine is not initialized</exception>
        public static IAsyncResult BeginValidateProperty(BaseModel model, object value, string propertyName, AsyncCallback callback, object state)
        {
            if (!_isInitialized)
                throw new InvalidOperationException("You must initialize the engine before it is used.");

            return new ValidatePropertyAsyncResult(CurrentValidator, model, value, propertyName, callback, state);
        }
        /// <summary>
        /// This method will validate a <see cref="BaseModel"/> asyncronously.  Also, if the children of the given
        /// model need to be validated at the same time, it can do that as well.
        /// </summary>
        /// <param name="target">A <see cref="BaseModel"/> to validate.</param>
        /// <param name="validateChildren">If the chilren of the given model should be validated as well, supply true.</param>
        /// <param name="callback">A <see cref="AsyncCallback"/> that will be called when the operation completes.</param>
        /// <param name="state">A user defined object providing state to the asycronous operation.</param>
        /// <returns>A <see cref="IAsyncResult"/> object representing the asyncronous operation.</returns>
        /// <exception cref="InvalidOperationException">If the engine is not initialized</exception>
        public static IAsyncResult BeginValidateModel(BaseModel target, bool validateChildren, AsyncCallback callback, object state)
        {
            if (!_isInitialized)
                throw new InvalidOperationException("You must initialize the engine before it is used.");

            return new ValidateModelAsyncResult(CurrentValidator, target, validateChildren, callback, state);
        }
Example #3
0
 public StaticPageBaseModel(BaseModel baseModel)
     : base(baseModel)
 {
     CurrentLanguage = LanguageType.Default;
     StaticPageTransport = new StaticPageTransport();
     SubNavigationType = SubNavigationType.None;
 }
Example #4
0
 public static void RegisterModel(BaseModel model)
 {
     var timer = new DispatcherTimer();
     timer.Interval = model.Interval;
     timer.Tick += model.TimerTick;
     timer.Start();
 }
 public BaseModel.OperationResult<int> CreateSolution(BaseModel.SolutionConfiguration solution)
 {
     return FunctionResultProxy.GetResult<OperationResult<int>>(delegate (OperationResult<int> r)
     {
         r.Data = SolutionConfigurationDal.Create(solution);
         r.ActionResult = (r.Data > 0);
         return r;
     });
 }
 public BaseModel.OperationResult<int> CreateComponentConfig(BaseModel.ComponentConfiguration componentConfig)
 {
     return FunctionResultProxy.GetResult<OperationResult<int>>(delegate (OperationResult<int> r)
     {
         r.Data = ComponentConfigurationDal.Create(componentConfig);
         r.ActionResult = (r.Data > 0);
         return r;
     });
 }
Example #7
0
        public BaseModel Create(BaseModel model)
        {
            Book entity = (Book) model;
            if (entity.IsValid)
            {
                _db.Books.Add(entity);
                _db.SaveChanges();
            }

            return entity;
        }
        public BaseModel Create(BaseModel model)
        {
            Category entity = (Category) model;
            if (entity.IsValid)
            {
                _db.Categories.Add(entity);
                _db.SaveChanges();
            }

            return entity;
        }
        /// <summary>
        /// Controller which returns the home index page. 
        /// No data calls or parameters are needed for this
        /// 
        /// Accessed via /Home/index
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            BaseModel model = new BaseModel();
            List<Breadcrumb> trail = new List<Breadcrumb>();

            trail.Add(new Breadcrumb() { LinkText = "Home", Action = "Index", Controller = "Home", isCurrent = true });

            model.Breadcrumbs = trail;

            return View(model);
        }
Example #10
0
        public static BaseModel CreateBaseModel(Guid sID)
        {
            

            BaseModel model = new BaseModel();
            model.Initialize(sID);
            model.Action = TabModelHelper.DefaultAction(sID);
            model.Controller = TabModelHelper.DefaultController(sID);            

            return model;
        }
        public BaseModel Create(BaseModel model)
        {
            Author entity = (Author)model;
            if (entity.IsValid)
            {
                _db.Authors.Add(entity);
                _db.SaveChanges();
            }

            return entity;
        }
Example #12
0
        public BaseModel Update(BaseModel model)
        {
            Book entity = _db.Books.Find(((Book) model).Id);

            if (entity == null)
                throw new NotImplementedException("Something needs to be done...");

            if (entity.IsValid)
            {
                _db.Entry(model).CurrentValues.SetValues(model);
                _db.SaveChanges();
            }

            return entity;
        }
        public JsonResult SetProductToSocet(string productId, string socetId, int count)
        {
            var model = new BaseModel();

            if ((productId != string.Empty) && (socetId != string.Empty) && (count > 0))
            {
                var result = SocetProductsService.AddProductIdToSocetId(productId, socetId, count);
                model = Mapper.Map<BaseModel>(result);
            }
            else
            {
                model.SetError(ResError.DataEmpty);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            BaseModel model = new BaseModel();
            model.HtmlTitle = _pageInfos[PageInfoType.HtmlTitle];
            model.HtmlMetaDescription = _pageInfos[PageInfoType.HtmlMetaDescription];
            model.TagModel = new TagModel { PageName = _pageInfos[PageInfoType.TagModel]};
            model.CssContainerId = _pageInfos[PageInfoType.CssContainerId];
            model.CssContainerClass = _pageInfos[PageInfoType.CssContainerClass];
            filterContext.Controller.ViewBag.OmnitureUrl = WebConfigurationManager.AppSettings["OmnitureSrc"];
            filterContext.Controller.ViewData.Model = model;

            // Default value for special omniture tags
            filterContext.Controller.ViewBag.OmnitureEvent = "";
            filterContext.Controller.ViewBag.OmnitureVar25 = "";

            base.OnActionExecuting(filterContext);
        }
Example #15
0
 public PhraseModel(BaseModel baseModel, List<PhraseEntityModel> phraseEntities)
     : base(baseModel)
 {
     PhraseEntities = phraseEntities;
 }
        /// <summary>
        /// This method will validate a property value in a <see cref="BaseModel"/> object.
        /// </summary>
        /// <param name="model">A <see cref="BaseModel"/> to validate.</param>
        /// <param name="value">The value to validate.</param>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <returns>A boolean value indicating whether the validation was successful or not.</returns>
        /// <exception cref="InvalidOperationException">If the engine is not initialized</exception>
        public static bool ValidateProperty(BaseModel model, object value, string propertyName)
        {
            if (!_isInitialized)
                throw new InvalidOperationException("You must initialize the engine before it is used.");

            IEnumerable<object> validationErrors = CurrentValidator.ValidateProperty(model, value, propertyName);
            ValidationErrorCollection errorCollection = (model as IValidationInteraction).ValidationErrors;

            CurrentManager.SetMemberErrors(errorCollection, validationErrors, propertyName);

            return validationErrors.Count() == 0;
        }
        /// <summary>
        /// This method will validate a <see cref="BaseModel"/>.  Also, if the children of the given
        /// model need to be validated at the same time, it can do that as well.
        /// </summary>
        /// <param name="model">A <see cref="BaseModel"/> to validate.</param>
        /// <param name="validateChildren">If the chilren of the given model should be validated as well, supply true.</param>
        /// <returns>A boolean value indicating whether the validation was successful or not.</returns>
        /// <exception cref="InvalidOperationException">If the engine is not initialized</exception>
        public static bool ValidateModel(BaseModel model, bool validateChildren = false)
        {
            if (!_isInitialized)
                throw new InvalidOperationException("You must initialize the engine before it is used.");

            IEnumerable<object> validationErrors = CurrentValidator.ValidateModel(model);
            ValidationErrorCollection errorCollection = (model as IValidationInteraction).ValidationErrors;

            CurrentManager.SetErrors(errorCollection, validationErrors);

            //If we're validating the children as well.
            if (validateChildren)
            {
                IEnumerable<PropertyInfo> properties = model.GetType().GetProperties().Where(a => a.CanRead && typeof(BaseModel).IsAssignableFrom(a.PropertyType));
                IEnumerable<PropertyInfo> colProperties = model.GetType().GetProperties().Where(a => a.CanRead && typeof(IEnumerable<BaseModel>).IsAssignableFrom(a.PropertyType));

                foreach (PropertyInfo pi in properties)
                    ValidateModel((BaseModel)pi.GetValue(model, null), validateChildren);
                foreach (PropertyInfo pi in colProperties)
                {
                    foreach (BaseModel bm in (IEnumerable<BaseModel>)pi.GetValue(model, null))
                        ValidateModel(bm, validateChildren);
                }
            }

            return validationErrors.Count() == 0;
        }
Example #18
0
 public DomainStatsModel(BaseModel baseModel, List<DomainStatsEntityModel> phraseDomains, PhraseEntityModel phrase)
     : base(baseModel)
 {
     Phrase = phrase;
     PhraseDomains = phraseDomains;
 }
Example #19
0
 public int SelectDataByID(string id, out BaseModel result)
 {
     return _dao.SelectDataByID(id, out result);
 }
Example #20
0
		public int SelectVocaSetsDataByID(string userID, int vocaSetID, out BaseModel result)
		{
			return _dao.SelectVocaSetsDataByID(userID, vocaSetID, out result);
		}
Example #21
0
		//public int SelectUserHomePageData(string userID, out BaseModel model)
		//{
		//	return _dao.SelectUserHomePageData(userID, out model);
		//}

        public int SelectData(BaseModel model, out IEnumerable<BaseModel> results)
        {
            return _dao.SelectData(model, out results);
        }
Example #22
0
		public int UpdateSetting(string userID, BaseModel model)
		{
			return _dao.UpdateSetting(userID, model);
		}
Example #23
0
 public int UpdateUserState(ref BaseModel result)
 {
     return _dao.UpdateUserState(ref result);
 }
Example #24
0
 public int Login(string email, string password, out BaseModel result)
 {
     return _dao.Login(email, password, out result);   
 }
Example #25
0
 public int UpdateData(BaseModel model)
 {
     return _dao.InsertData(model);
 }
Example #26
0
 /// <summary>
 /// Sets the values of its own variables from the given snapshot
 /// </summary>
 /// <param name="snapshot"></param>
 public abstract void ImportValues(BaseModel snapshot);
 /// <summary>
 /// Inherited from <see cref="IValidator"/>
 /// <remarks>This implementation returns all results at once.  This means that all 
 /// asyncronous operations complete before a result is returned.</remarks>
 /// </summary>
 /// <param name="model">A <see cref="BaseModel"/> that will be validated.</param>
 /// <param name="callback">An <see cref="AsyncCallback"/> reference that will be called when the operation completes.</param>
 /// <param name="state">A user defined object.</param>
 /// <returns>An <see cref="IAsyncResult"/> representing the background operation.</returns>
 public virtual IAsyncResult BeginValidateModel(BaseModel model, AsyncCallback callback, object state)
 {
     return new DefaultValidateModelAsyncResult(model, this, callback, state);
 }
 /// <summary>
 /// Inherited from <see cref="IValidator"/>
 /// <remarks>This implementation returns all results at once.  This means that all 
 /// asyncronous operations complete before a result is returned.</remarks>
 /// </summary>
 /// <param name="model">A <see cref="BaseModel"/> that will be validated.</param>
 /// <param name="value">The value that needs to be validated.</param>
 /// <param name="propertyName">The name of the property who's value has changed and needs to be validated.</param>
 /// <param name="callback">An <see cref="AsyncCallback"/> reference that will be called when the operation completes.</param>
 /// <param name="state">A user defined object.</param>
 /// <returns>An <see cref="IAsyncResult"/> representing the background operation.</returns>
 public virtual IAsyncResult BeginValidateProperty(BaseModel model, object value, string propertyName, AsyncCallback callback, object state)
 {
     return new DefaultValidatePropertyAsyncResult(model, this, value, propertyName, callback, state);
 }
        /// <summary>
        /// Call this method to clear all validation issues with a given model.
        /// </summary>
        /// <param name="model">A <see cref="BaseModel"/> to clear validation issues from.</param>
        /// <param name="clearChildIssues">A boolean value indicating whether or not to clear child objects issues as well.</param>
        public static void ClearValidationIssues(BaseModel model, bool clearChildIssues = false)
        {
            if (model == null)
                return;

            (model as IValidationInteraction).ValidationErrors.Clear();

            if (clearChildIssues)
            {
                IEnumerable<PropertyInfo> properties = model.GetType().GetProperties().Where(a => a.CanRead && typeof(BaseModel).IsAssignableFrom(a.PropertyType));
                IEnumerable<PropertyInfo> colProperties = model.GetType().GetProperties().Where(a => a.CanRead && typeof(IEnumerable<BaseModel>).IsAssignableFrom(a.PropertyType));

                foreach (PropertyInfo pi in properties)
                    ClearValidationIssues((BaseModel)pi.GetValue(model, null), clearChildIssues);
                foreach (PropertyInfo pi in colProperties)
                {
                    foreach (BaseModel bm in (IEnumerable<BaseModel>)pi.GetValue(model, null))
                        ClearValidationIssues(bm, clearChildIssues);
                }
            }
        }
Example #30
0
 public StatusModel(BaseModel baseModel, ProgressStatusSummary serverProgress)
     : base(baseModel)
 {
     ServerProgress = serverProgress;
 }