public async Task <ActionResult> Enable(int?id) { var obj = new UomViewModel(); var url = "api/Uom/GetById/" + id; var response = await HttpClientHelper.ApiCall(url, Method.GET); if (response.IsSuccessful) { var result = response.Content; obj = JsonConvert.DeserializeObject <UomViewModel>(result); } return(PartialView(obj)); }
// GET: MealPlan/Create public ActionResult Create() { MealPlanViewModel mealPlanDisplay = new MealPlanViewModel(); mealPlanDisplay.Preparations = new List <PreparationViewModel>(); mealPlanDisplay.Preparations.Add(new PreparationViewModel()); MealPlanAssignedCategoryRepository mealPlanAssignedCategoryRepository = new MealPlanAssignedCategoryRepository(); mealPlanDisplay.MealPlanAssignedCategories = mealPlanAssignedCategoryRepository.GetDisplayList(0); MealPlanAssignedDietPlanRepository mealPlanAssignedDietPlanRepository = new MealPlanAssignedDietPlanRepository(); mealPlanDisplay.MealPlanAssignedDietPlans = mealPlanAssignedDietPlanRepository.GetDisplayList(0); NutrientViewModel nutrientViewModel = new NutrientViewModel(); mealPlanDisplay.NutrientDropDownList = nutrientViewModel.GetDropDownList(); MealPlanAssignedNutrientRepository mealPlanAssignedNutrientRepository = new MealPlanAssignedNutrientRepository(); mealPlanDisplay.MealPlanAssignedNutrients = mealPlanAssignedNutrientRepository.GetDisplayList(0); mealPlanDisplay.MealPlanAssignedNutrients.Add(new MealPlanAssignedNutrientViewModel()); MealPlanAssignedDishRepository mealPlanAssignedDishRepository = new MealPlanAssignedDishRepository(); mealPlanDisplay.MealPlanAssignedDishes = mealPlanAssignedDishRepository.GetDisplayList(0); mealPlanDisplay.MealPlanAssignedDishes.Add(new MealPlanAssignedDishViewModel()); MealPlanAssignedIngredientRepository mealPlanAssignedIngredientRepository = new MealPlanAssignedIngredientRepository(); mealPlanDisplay.MealPlanAssignedIngredients = mealPlanAssignedIngredientRepository.GetDisplayList(0); mealPlanDisplay.MealPlanAssignedIngredients.Add(new MealPlanAssignedIngredientViewModel()); UomViewModel uomViewModel = new UomViewModel(); mealPlanDisplay.UomDropDownList = uomViewModel.GetDropDownList(); DishViewModel dishViewModel = new DishViewModel(); mealPlanDisplay.DishDropDownList = dishViewModel.GetDropDownList(); IngredientViewModel ingredientViewModel = new IngredientViewModel(); mealPlanDisplay.IngredientDropDownList = ingredientViewModel.GetDropDownList(); return(View(mealPlanDisplay)); }
public UomViewModel MapToViewModel(Uom uom) { UomViewModel uomVM = new UomViewModel { Id = uom.Id, _IsDeleted = uom._IsDeleted, Active = uom.Active, _CreatedUtc = uom._CreatedUtc, _CreatedBy = uom._CreatedBy, _CreatedAgent = uom._CreatedAgent, _LastModifiedUtc = uom._LastModifiedUtc, _LastModifiedBy = uom._LastModifiedBy, _LastModifiedAgent = uom._LastModifiedAgent, Unit = uom.Unit }; return(uomVM); }
public Uom MapToModel(UomViewModel uomVM) { Uom uom = new Uom { Id = uomVM.Id, UId = uomVM.UId, _IsDeleted = uomVM._IsDeleted, Active = uomVM.Active, _CreatedUtc = uomVM._CreatedUtc, _CreatedBy = uomVM._CreatedBy, _CreatedAgent = uomVM._CreatedAgent, _LastModifiedUtc = uomVM._LastModifiedUtc, _LastModifiedBy = uomVM._LastModifiedBy, _LastModifiedAgent = uomVM._LastModifiedAgent, Unit = uomVM.Unit }; return(uom); }
public void Should_Succes_Instantiate_ProductViewModel() { string id = "id test"; string code = "code test"; string nama = "name test"; double Price = 1.1; UomViewModel uvm = new UomViewModel(); ProductViewModel pvm = new ProductViewModel(); pvm.Id = id; pvm.Name = nama; pvm.Code = code; pvm.Price = Price; pvm.UOM = uvm; Assert.Equal(id, pvm.Id); Assert.Equal(nama, pvm.Name); Assert.Equal(code, pvm.Code); Assert.Equal(Price, pvm.Price); Assert.NotNull(pvm.UOM); }
public TransferRequestViewModel MapToViewModel(TransferRequest model) { TransferRequestViewModel viewModel = new TransferRequestViewModel(); viewModel.trDate = model.TRDate; viewModel.remark = model.Remark; viewModel.unitId = model.UnitId; viewModel.unitName = model.UnitName; viewModel.unitCode = model.UnitCode; viewModel.categoryId = model.CategoryId; viewModel.categoryCode = model.CategoryCode; viewModel.categoryName = model.CategoryName; viewModel.divisionId = model.DivisionId; viewModel.divisionCode = model.DivisionCode; viewModel.divisionName = model.DivisionName; viewModel.requestedArrivalDate = model.RequestedArrivalDate; PropertyCopier <TransferRequest, TransferRequestViewModel> .Copy(model, viewModel); UnitViewModel Unit = new UnitViewModel() { _id = model.UnitId, code = model.UnitCode, name = model.UnitName, divisionId = model.DivisionId, divisionCode = model.DivisionCode, divisionName = model.DivisionName }; CategoryViewModel Category = new CategoryViewModel() { _id = model.CategoryId, code = model.CategoryCode, name = model.CategoryName, }; viewModel.trNo = model.TRNo; viewModel.unit = Unit; viewModel.category = Category; viewModel.remark = model.Remark; viewModel.trDate = model.TRDate; viewModel.requestedArrivalDate = model.RequestedArrivalDate; viewModel.isPosted = model.IsPosted; viewModel.isCanceled = model.IsCanceled; viewModel.details = new List <TransferRequestDetailViewModel>(); if (model.TransferRequestDetails != null) { foreach (TransferRequestDetail transferRequestDetail in model.TransferRequestDetails) { TransferRequestDetailViewModel transferRequestDetailViewModel = new TransferRequestDetailViewModel(); PropertyCopier <TransferRequestDetail, TransferRequestDetailViewModel> .Copy(transferRequestDetail, transferRequestDetailViewModel); UomViewModel Uom = new UomViewModel() { _id = transferRequestDetail.UomId, unit = transferRequestDetail.UomUnit }; transferRequestDetailViewModel.uom = Uom; transferRequestDetailViewModel.quantity = transferRequestDetail.Quantity; transferRequestDetailViewModel.grade = transferRequestDetail.Grade; ProductViewModel Product = new ProductViewModel() { _id = transferRequestDetail.ProductId, code = transferRequestDetail.ProductCode, name = transferRequestDetail.ProductName }; transferRequestDetailViewModel.product = Product; transferRequestDetailViewModel.productRemark = transferRequestDetail.ProductRemark; transferRequestDetailViewModel.status = transferRequestDetail.Status; transferRequestDetailViewModel.grade = transferRequestDetail.Grade; viewModel.details.Add(transferRequestDetailViewModel); } } return(viewModel); }