public void AutoMapperTestForFlattening()
        {
            //Mapper.CreateMap<ModelA, NewModel>().ForMember(dest=> dest.Number ,opt=>opt.UseDestinationValue());

            NewModel newModel = new NewModel() { Number = "47"}, destModel = new NewModel(){Number="127"};
            NewModel new2 = newModel;
            ModelA modelA = new ModelA
            {
                Id = Guid.NewGuid(),
                InnerModel = new ModelB
                {
                    InnerModel = new ModelC { FirstNumber = "456", Name = "Flattening" },
                    SecondNumber = "123"
                }
            };
            //newModel = Mapper.Map<ModelA, NewModel>(modelA, destModel);
            var a = Mapper.Map<ModelA, NewModel>(new ModelA() { Id = Guid.NewGuid() });
            Assert.AreEqual(newModel.Id, modelA.Id);
            Assert.AreEqual(newModel.Number, "456123");
            Assert.AreEqual(newModel.InnerModelInnerModelName, "Flattening");
        }
Esempio n. 2
0
 public int AddAdmin(NewModel newModel)
 {
     return(adUser.AddAdmin(newModel));
 }
Esempio n. 3
0
 private async void SelectedNewModelExecute(NewModel value)
 {
     await((MasterDetailPage)(Application.Current.MainPage)).Detail.Navigation.PushAsync(new NewPage(value));
     ((MasterDetailPage)(Application.Current.MainPage)).IsPresented = false;
 }
Esempio n. 4
0
        //#endregion
        #endregion
        #endregion

        #region GetNewDetail    4.0 获取咨询详情
        public string GetNewDetail(string pContent)
        {
            var rd = new APIResponse <NewDetailRD>();

            try
            {
                //解析请求字符串
                var rp = pContent.DeserializeJSONTo <APIRequest <NewDetailRP> >();
                if (rp.Parameters != null)
                {
                    rp.Parameters.Validate();
                }

                #region
                if (rp.Parameters == null)
                {
                    rd.ResultCode = 101;
                    rd.Message    = "没有特殊参数";
                    return(rd.ToJSON());
                }

                string customerID = rp.CustomerID;
                //判断客户ID是否传递
                if (string.IsNullOrEmpty(customerID))
                {
                    rd.ResultCode = 100;
                    rd.Message    = "CustomerID不能为空";
                    return(rd.ToJSON());
                }

                if (string.IsNullOrEmpty(rp.Parameters.NewID))
                {
                    rd.ResultCode = 102;
                    rd.Message    = "NewsID不能为空";
                    return(rd.ToJSON());
                }
                #endregion

                var      loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
                DataSet  ds    = new LNewsBLL(loggingSessionInfo).GetNewDetail(customerID, rp.Parameters.NewID);
                NewModel model = new NewModel();
                if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    model = DataTableToObject.ConvertToList <NewModel>(ds.Tables[0]).FirstOrDefault();
                }

                var rdData = new NewDetailRD();
                rdData.New = model;
                rd.Data    = rdData;
                rd.Message = "获取咨询详情成功";

                return(rd.ToJSON());
            }
            catch (Exception ex)
            {
                rd.ResultCode = 104;
                rd.Message    = ex.ToString();
            }

            return(string.Empty);
        }
        public async Task <Object> ChangeAirlineMainInfo(string airlineID, NewModel model)
        {
            var resultFind = await _context.Airlines.FindAsync(int.Parse(airlineID));

            if (resultFind == null)
            {
                return(NotFound());
            }

            int emptyIndicator = 0;

            if (model.Name != null)
            {
                if (!model.Name.Trim().Equals(""))
                {
                    resultFind.AirlineName = model.Name;
                }
                else
                {
                    ++emptyIndicator;
                }
            }
            else
            {
                ++emptyIndicator;
            }

            if (model.Address != null)
            {
                if (!model.Address.Trim().Equals(""))
                {
                    resultFind.AirlineAddress = model.Address;
                }
                else
                {
                    ++emptyIndicator;
                }
            }
            else
            {
                ++emptyIndicator;
            }

            if (model.PromotionDescription != null)
            {
                if (!model.PromotionDescription.Trim().Equals(""))
                {
                    resultFind.AirlinePromotionDescription = model.PromotionDescription;
                }
                else
                {
                    ++emptyIndicator;
                }
            }
            else
            {
                ++emptyIndicator;
            }

            if (model.PriceList != null)
            {
                if (!model.PriceList.Trim().Equals(""))
                {
                    resultFind.AirlinePriceList = model.PriceList;
                }
                else
                {
                    ++emptyIndicator;
                }
            }
            else
            {
                ++emptyIndicator;
            }

            if (emptyIndicator == 4)
            {
                return(NotFound("You not entered any new data."));
            }
            else
            {
                try
                {
                    _context.Airlines.Update(resultFind);
                    _context.SaveChanges();
                    return(Ok());
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
Esempio n. 6
0
        public async Task <string> RenderAsync(SerializableList <User> model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            bool header = PropData.GetAdditionalAttributeValue("Header", true);

            GridModel grid = new GridModel()
            {
                GridDef = GetGridModel(header)
            };

            grid.GridDef.DirectDataAsync = async(int skip, int take, List <DataProviderSortInfo> sorts, List <DataProviderFilterInfo> filters) => {
                List <Entry> list = new List <Entry>();
                using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) {
                    if (model != null)
                    {
                        foreach (User user in model)
                        {
                            UserDefinition userDef = await userDP.GetItemByUserIdAsync(user.UserId);

                            string userName;
                            if (userDef == null)
                            {
                                userName = __ResStr("noUser", "({0})", user.UserId);
                            }
                            else
                            {
                                userName = userDef.UserName;
                            }
                            list.Add(new Entry(user.UserId, userName));
                        }
                    }
                }
                return(new DataSourceResult {
                    Data = list.ToList <object>(),
                    Total = list.Count
                });
            };

            hb.Append($@"
<div class='yt_yetawf_identity_listofusernames t_edit' id='{DivId}'>
    {await HtmlHelper.ForDisplayAsAsync(Container, PropertyName, FieldName, grid, nameof(grid.GridDef), grid.GridDef, "Grid", HtmlAttributes: HtmlAttributes)}");

            using (Manager.StartNestedComponent(FieldName)) {
                NewModel newModel = new NewModel();
                hb.Append($@"
    <div class='t_newvalue'>
        {await HtmlHelper.ForLabelAsync(newModel, nameof(newModel.NewValue))}
        {await HtmlHelper.ForEditAsync(newModel, nameof(newModel.NewValue), Validation: false)}
        <input name='btnAdd' type='button' value='Add' disabled='disabled' />
    </div>");
            }

            GridModel gridAll = new GridModel()
            {
                GridDef = GetGridAllUsersModel()
            };
            ListOfUserNamesSetup setup = new ListOfUserNamesSetup {
                AddUrl    = Utility.UrlFor(typeof(ListOfUserNamesController), nameof(ListOfUserNamesController.AddUserName)),
                GridId    = grid.GridDef.Id,
                GridAllId = gridAll.GridDef.Id
            };

            hb.Append($@"
    <div id='{DivId}_coll'>
        {await ModuleActionHelper.BuiltIn_ExpandAction(__ResStr("lblFindUsers", "Find Users"), __ResStr("ttFindUsers", "Expand to find user names available on this site")).RenderAsNormalLinkAsync() }
    </div>
    <div id='{DivId}_exp' style='display:none'>
        {await ModuleActionHelper.BuiltIn_CollapseAction(__ResStr("lblAllUserNames", "All User Names"), __ResStr("ttAllUserNames", "Shows all user names available on this site - Select a user name to update the text box above, so the user name can be added to the list of user names - Click to close")).RenderAsNormalLinkAsync() }
        {await HtmlHelper.ForDisplayAsAsync(Container, PropertyName, FieldName, gridAll, nameof(gridAll.GridDef), gridAll.GridDef, "Grid")}
    </div>
</div>");

            Manager.ScriptManager.AddLast($@"
$YetaWF.expandCollapseHandling('{DivId}', '{DivId}_coll', '{DivId}_exp');
new YetaWF_Identity.ListOfUserNamesEditComponent('{DivId}', {Utility.JsonSerialize(setup)});");

            return(hb.ToString());
        }