public void SelectedText_ListEmpty() { // setup var mod = new SortCategoryViewModel(); // sense Assert.Equal(null, mod.SelectedText); }
/// <summary> /// Convert SortCategory Entity into SortCategory Object /// </summary> ///<param name="model">SortCategoryViewModel</param> ///<param name="SortCategoryEntity">DataAccess.SortCategory</param> ///<returns>SortCategoryViewModel</returns> public static SortCategoryViewModel ToViewModel( this DataAccess.SortCategory entity, SortCategoryViewModel model) { model.SessionUserId = entity.CreatedUserId; model.Id = entity.Id; model.Name = entity.Name; model.Discriminator = entity.Discriminator; model.Ordinal = entity.Ordinal; return(model); }
public void SelectedText_Sel() { // setup var mod = new SortCategoryViewModel(); mod.Items.Add(new Option { Selected = false, Name = "t1", Value = "v1" }); mod.Items.Add(new Option { Selected = true, Name = "t2", Value = "v1" }); mod.Items.Add(new Option { Selected = false, Name = "t3", Value = "v1" }); // sense Assert.Equal("t2", mod.SelectedText); }
/// <summary> /// Convert SortCategory Object into SortCategory Entity /// </summary> ///<param name="model">SortCategory</param> ///<param name="SortCategoryEntity">DataAccess.SortCategory</param> ///<returns>DataAccess.SortCategory</returns> public static DataAccess.SortCategory ToEntity(this SortCategoryViewModel model, DataAccess.SortCategory entity) { if (entity.Id == 0) { entity.CreatedUserId = model.SessionUserId; } else { entity.UpdatedUserId = model.SessionUserId; entity.UpdatedTimestamp = DateTime.Now; } entity.Name = model.Name; entity.Discriminator = model.Discriminator; entity.Ordinal = model.Ordinal; return(entity); }
public ActionResult Browse(string category, string name = null, int page = 1, string cost = null) { int PageSize = 1; IEnumerable <ItemDTO> datas; switch (cost) { case "to-cheap": datas = serviceItem.SortedDatas(category); break; default: datas = serviceItem.DatasMatchingCategories(page, PageSize, name, category); break; } var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ItemDTO, ItemViewModel>()).CreateMapper(); ViewBag.ItemName = name; SortCategoryViewModel _model = new SortCategoryViewModel { CategoryModel = serviceCategory.GetCategory(category), DescriptionModel = serviceDescription.GetDescriptionCategory(category), CurrentCategory = name, Info = new InfoOfPage { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = serviceItem.Count(name, category) }, Items = mapper.Map <IEnumerable <ItemDTO>, IList <ItemViewModel> >(datas) }; //var categoryModel = serviceCategory.GetCategory(category); return(View(_model)); }