Ejemplo n.º 1
0
        private async static Task <string> TestNewEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test creating a new  BO");
                var obj = await BOFactory.NewBOAsync(pType.ToString(), Data);

                BOFactory.ApplyPreset(obj, Data);

                var saved = await(obj as SPC.Interfaces.IEditable).SaveBOAsync();

                Console.WriteLine("New object Saved: ");

                var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                Console.WriteLine(jsonstr);


                return(saved.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(string.Empty);
        }
Ejemplo n.º 2
0
        private async static Task TestUpdateEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test update existing  BO");

                var obj = await BOFactory.GetBOAsync(pType.ToString(), Data);

                BOFactory.ApplyPreset(obj, Data);

                var saved = await(obj as SPC.Interfaces.IEditable).SaveBOAsync();

                Console.WriteLine("Object has been amended: ");

                var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                Console.WriteLine(jsonstr);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        async Task OnRowUpdating(CompanyUserInfo dataItem, IDictionary <string, object> newValue)
        {
            if (dataItem != null && newValue != null && newValue.Count > 0)
            {
                Status = $"Cập nhật tài khoản {dataItem.UserId}";

                StateHasChanged();

                var itm = await SPC.Cloud.Members.CompanyUser.GetCompanyUserAsync(dataItem.UserId, dataItem.CompanyId);

                Dictionary <string, string> dic = CreateStringDic(newValue);

                BOFactory.ApplyPreset(itm, dic);

                await itm.SaveAndMergeAsync();

                await CompanyUser.CreateSubscriberIfNotExistsAsync(itm.CompanyId, itm.UserId, dic);

                await SearchAsync();
            }
            //await ForecastService.Update(dataItem, newValue);
        }