CommodityTypeViewModel Map(CommodityType commodityType)
        {


            CommodityTypeViewModel commodityTypeView = new CommodityTypeViewModel();
            commodityTypeView.Id = commodityType.Id;
            commodityTypeView.Code = commodityType.Code;
            commodityTypeView.Description = commodityType.Description;
            commodityTypeView.Name = commodityType.Name;
            commodityTypeView.IsActive = (int) commodityType._Status;

            return commodityTypeView;
        }
 public void Save(CommodityTypeViewModel commodityTypeViewmodel)
 {
     CommodityType commodityType = new CommodityType(commodityTypeViewmodel.Id);
     commodityType.Name = commodityTypeViewmodel.Name;
     commodityType.Description = commodityTypeViewmodel.Description;
     commodityType.Code = commodityTypeViewmodel.Code;
     commodityType._Status = EntityStatus.Active;
     _commodityTypeRepository.Save(commodityType);
 }
Пример #3
0
         public ActionResult CreateCommodityType(CommodityTypeViewModel vm)
         {
             ViewBag.RegionList = _commodityTypeViewModelBuilder.Region();
             
             try
             {
                 vm.Id = Guid.NewGuid();
                 _commodityTypeViewModelBuilder.Save(vm);
                 
                 TempData["msg"] = "Commodity Type Successfully Created";

                 return RedirectToAction("ListCommodityTypes");
             }
             catch (DomainValidationException ve)
             {
                 ValidationSummary.DomainValidationErrors(ve, ModelState);
                 _log.Debug("Failed to create asset categories " + ve.Message);
                 _log.Error("Failed to create asset categories" + ve.ToString());

                 return View(vm);
             }
             catch (Exception ex)
             {
                 ModelState.AddModelError("", ex.Message);
                 _log.Debug("Failed to create asset categories " + ex.Message);
                 _log.Error("Failed to create asset categories" + ex.ToString());

                 return View(vm);
             }

         }