public EssenceSOR <Immovables> CancelEdit() { var operationResult = new EssenceSOR <Immovables>(); try { var tempIr = new ImmoRepos(); var d = tempIr.LoadByLinq(x => x.Id == immoEdit.Id).First(); foreach (PropertyInfo myProp in ImmoProperty) { string propName = myProp.Name; foreach (PropertyInfo oldProp in ImmoProperty) { string oldpropName = oldProp.Name; if (propName == oldpropName) { myProp.SetValue(immoEdit, oldProp.GetValue(d)); } } } operationResult.Essence = immoEdit; return(operationResult); } catch (Exception e) { operationResult.Message = e.Message; operationResult.IsSuccess = true; } return(operationResult); }
public EssenceSOR <Immovables> SetImmovablesFieldValue(string fieldName, object val) { var operationResult = new EssenceSOR <Immovables>(); try { var prop = ImmoProperty.FirstOrDefault(myProp => myProp.Name == fieldName); var t = prop.PropertyType; if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable <>))) { if (val == null) { operationResult.Message = "Поле нельзя оставить пустым"; operationResult.IsSuccess = true; return(operationResult); } t = Nullable.GetUnderlyingType(t); } prop.SetValue(immoEdit, Convert.ChangeType(val, t)); operationResult.Essence = immoEdit; } catch (Exception e) { throw new FaultException($"{e.Message}"); } return(operationResult); }
public EssenceSOR <Immovables> StartImmovablesEdit(int id) { var operationResult = new EssenceSOR <Immovables>(); try { immoEdit = ir.LoadByID(id); operationResult.Essence = immoEdit; } catch (Exception e) { operationResult.Message = e.Message; operationResult.IsSuccess = true; } return(operationResult); }