public OperationResult Update(DataForm formObject)
        {
            OperationResult result = new OperationResult(true, formObject);

            //formValidator = Factory.Create<IFormValidator>(this.Key, ClassType.clsTypeFormValidator);
            ValidationResult validationResult = formValidator.Validate(formObject);

            if (validationResult.Result)
            {
                Object o = Factory.Create <Object>(this.Key, ClassType.clsTypeDataModel);
                System.Reflection.PropertyInfo propertyInfo = Wiseape.Utility.Assembly.GetKeyProperty(o.GetType());
                object id = formObject.GetType().GetProperty(propertyInfo.Name).GetValue(formObject, null);

                businessService = Factory.Create <IBusinessService>(this.Key, ClassType.clsTypeBusinessService);
                OperationResult res = businessService.Get(id);
                o = res.Data;

                formDataConverter = Factory.Create <IFormDataConverter>(this.Key, ClassType.clsTypeFormProcessor);
                formDataConverter.PopulateData(formObject, o);

                result = businessService.Update(o);
            }
            else
            {
                result.Result  = false;
                result.Message = "Validation Error";
                result.Data    = validationResult;
            }
            return(result);
        }
        protected virtual void ConvertListToFormList(OperationResult result, string key)
        {
            if (result.Result)
            {
                IFormDataConverter formDataConverter = Factory.Create <IFormDataConverter>(key, ClassType.clsTypeFormProcessor);

                List <object> list         = result.Data as List <object>;
                List <object> dataFormList = new List <object>();
                foreach (object obj in list)
                {
                    object dataForm = Factory.Create(key, ClassType.clsTypeForm);
                    formDataConverter.PopulateForm(obj, dataForm);
                    string   path      = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri.AbsoluteUri;
                    string[] sfilename = path.Split(new char[] { '/' });
                    string   filename  = "";
                    if (sfilename.Length > 0)
                    {
                        filename = sfilename[sfilename.Length - 1];
                    }
                    path = path.Replace(filename + "/", "");
                    path = path.Replace(filename, "");
                    path = path.Substring(0, path.Length - 1);

                    ((DataForm)dataForm).BaseUrl = path + "/Resources/Uploads";

                    dataFormList.Add(dataForm);
                }
                result.Data = dataFormList;
            }
        }
 protected virtual void ConvertObjectToForm(OperationResult result, string key)
 {
     if (result.Result)
     {
         IFormDataConverter formDataConverter = Factory.Create <IFormDataConverter>(key, ClassType.clsTypeFormProcessor);
         object             dataForm          = Factory.Create(key, ClassType.clsTypeForm);
         formDataConverter.PopulateForm(result.Data, dataForm);
         result.Data = dataForm;
     }
 }
        public OperationResult Add(DataForm formObject)
        {
            OperationResult result = new OperationResult(true, formObject);

            //formValidator = Factory.Create<IFormValidator>(this.Key, ClassType.clsTypeFormValidator);
            ValidationResult validationResult = formValidator.Validate(formObject);

            if (validationResult.Result)
            {
                formDataConverter = Factory.Create <IFormDataConverter>(this.Key, ClassType.clsTypeFormProcessor);
                Object o = Factory.Create <Object>(this.Key, ClassType.clsTypeDataModel);
                formDataConverter.PopulateData(formObject, o);

                businessService = Factory.Create <IBusinessService>(this.Key, ClassType.clsTypeBusinessService);
                result          = businessService.Add(o);
            }
            else
            {
                result.Result  = false;
                result.Message = "Validation Error";
                result.Data    = validationResult;
            }
            return(result);
        }