예제 #1
0
 /* refreshes the houses in a franchise this method is called while creating the Franchise view mmodel */
 public void RefreshCompanyHouses(IEnumerable <Houses> houses)
 {
     Houses.Clear();
     foreach (Houses house in houses)
     {
         AddNewHouse(house);
     }
 }
 public Schema()
     : base()
 {
     InstanceType = typeof(__SingleFr__);
     Properties.ClearExposed();
     Html = Add <__TString__>("Html");
     Html.DefaultValue = "/Noman/SingleFranchiseeView.html";
     Html.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__Html__ = (System.String)_v_; }, false);
     Name = Add <__TString__>("Name$");
     Name.DefaultValue = "";
     Name.Editable     = true;
     Name.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__Name__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__Name__ = (System.String)_v_; }, false);
     Houses = Add <__TArray__>("Houses");
     Houses.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__Houses__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__Houses__ = (__Arr__)_v_; }, false);
     House_No = Add <__TString__>("House_No$");
     House_No.DefaultValue = "";
     House_No.Editable     = true;
     House_No.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__House_No__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__House_No__ = (System.String)_v_; }, false);
     Street = Add <__TString__>("Street$");
     Street.DefaultValue = "";
     Street.Editable     = true;
     Street.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__Street__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__Street__ = (System.String)_v_; }, false);
     ZipCode = Add <__TString__>("ZipCode$");
     ZipCode.DefaultValue = "";
     ZipCode.Editable     = true;
     ZipCode.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__ZipCode__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__ZipCode__ = (System.String)_v_; }, false);
     City = Add <__TString__>("City$");
     City.DefaultValue = "";
     City.Editable     = true;
     City.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__City__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__City__ = (System.String)_v_; }, false);
     State = Add <__TString__>("State$");
     State.DefaultValue = "";
     State.Editable     = true;
     State.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__State__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__State__ = (System.String)_v_; }, false);
     Country = Add <__TString__>("Country$");
     Country.DefaultValue = "";
     Country.Editable     = true;
     Country.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__Country__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__Country__ = (System.String)_v_; }, false);
     CompleteAddress = Add <__TString__>("CompleteAddress", bind: "CompleteAddress");
     CompleteAddress.DefaultValue = "";
     CompleteAddress.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__CompleteAddress__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__CompleteAddress__ = (System.String)_v_; }, false);
     CreateNewHouse = Add <__TLong__>("CreateNewHouse$");
     CreateNewHouse.DefaultValue = 0L;
     CreateNewHouse.Editable     = true;
     CreateNewHouse.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__CreateNewHouse__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__CreateNewHouse__ = (System.Int64)_v_; }, false);
     CreateNewHouse.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.CreateNewHouse()
         {
             App = (SingleFranchiseeView)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((SingleFranchiseeView)pup).Handle((Input.CreateNewHouse)input); });
     SaveCurrentFranchiseeInfo = Add <__TLong__>("SaveCurrentFranchiseeInfo$");
     SaveCurrentFranchiseeInfo.DefaultValue = 0L;
     SaveCurrentFranchiseeInfo.Editable     = true;
     SaveCurrentFranchiseeInfo.SetCustomAccessors((_p_) => { return(((__SingleFr__)_p_).__bf__SaveCurrentFranchiseeInfo__); }, (_p_, _v_) => { ((__SingleFr__)_p_).__bf__SaveCurrentFranchiseeInfo__ = (System.Int64)_v_; }, false);
     SaveCurrentFranchiseeInfo.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.SaveCurrentFranchiseeInfo()
         {
             App = (SingleFranchiseeView)pup, Template = (TLong)prop, Value = value
         }); }, (Json pup, Starcounter.Input <Int64> input) => { ((SingleFranchiseeView)pup).Handle((Input.SaveCurrentFranchiseeInfo)input); });
 }
예제 #3
0
        // Create new house of model type and calls its respective viewmodel  function to create a viewmodel house
        void Handle(Input.CreateNewHouse action)
        {
            var newHouse = new Houses()
            {
                CaretakerCompany = (Franchisee)Data
            };

            AddNewHouse(newHouse);
        }
예제 #4
0
        /*View Manipulation Methods*/


        // creating viewmodel house from model Houses data
        public void AddNewHouse(Houses newhouse)
        {
            var houseJson = new HousesView()
            {
                Data = newhouse
            };

            Houses.Add(houseJson);
        }
예제 #5
0
        public static void Register()
        {
            // Request Handler for a single house

            Handle.GET("/Noman/partial/house/{?}", (string id) =>
            {
                var json  = new HousesView();
                json.Data = (Houses)DbHelper.FromID(DbHelper.Base64DecodeObjectID(id));
                return(json);
            });

            Handle.GET("/Noman/house/{?}", (string id) =>
            {
                return(Db.Scope(() =>
                {
                    var json = new SingleHouseView();

                    Houses house = (Houses)DbHelper.FromID(DbHelper.Base64DecodeObjectID(id));
                    json.Data = house;

                    if (Session.Current == null)
                    {
                        Session.Current = new Session(SessionOptions.PatchVersioning);
                    }
                    if (Session.Current.Data is HousesView)
                    {
                        return Session.Current.Data;
                    }


                    json.Session = Session.Current;

                    return json;
                }));
            });
        }