public void Save(CommodityViewModel commodityViewModel)
        {
            Commodity Commodity = new Commodity(commodityViewModel.Id);
            Commodity.Name = commodityViewModel.Name;
            Commodity.Code = commodityViewModel.Code;
            Commodity.Description = commodityViewModel.Description;
            Commodity.CommodityType = _commodityTypeRepository.GetById(commodityViewModel.CommodityTypeId);
            _commodityRepository.Save(Commodity);

        }
 private void AssertCommodity(Commodity commodity, Commodity savedCommodity)
 {
     Assert.AreEqual(commodity.Code, savedCommodity.Code);
     Assert.AreEqual(commodity.Name, savedCommodity.Name);
     Assert.AreEqual(commodity.Description, savedCommodity.Description);
     Assert.AreEqual(commodity._Status, savedCommodity._Status);
 }
 public CommodityDTO Map(Commodity commodity)
 { 
     if (commodity == null) return null;
     var commodityDto = Mapper.Map<Commodity, CommodityDTO>(commodity);
     commodityDto.CommodityGrades = commodity.CommodityGrades.Select(n => Map(n, commodity.Id)).ToList();
     return commodityDto;
 }
        private CommodityViewModel Map(Commodity commodity)
        {

            CommodityViewModel viewModel = new CommodityViewModel();
            {

                viewModel.Id = commodity.Id;
                if (commodity.CommodityType.Id != null)
                {
                    viewModel.CommodityTypeId = commodity.CommodityType.Id;

                }
                if (_commodityTypeRepository.GetById(commodity.CommodityType.Id).Name != null)
                {
                    viewModel.CommodityTypeName = _commodityTypeRepository.GetById(commodity.CommodityType.Id).Name;
                }
                viewModel.CommodityTypeId = commodity.CommodityType.Id;
                viewModel.Name = commodity.Name;
                viewModel.Code = commodity.Code;
                viewModel.Description = commodity.Description;

                viewModel.Active = commodity._Status == EntityStatus.Active ? true : false;
            };
            return viewModel;
        }
Example #5
0
 public bool CheckCommodityIsUsed(Commodity commodity, EntityStatus intendedStatus)
 {
     if(_ctx.tblSourcingLineItem.Any(n => n.CommodityId == commodity.Id))
         return true;
     if(intendedStatus == EntityStatus.Inactive)
     {
         if(commodity.CommodityGrades.Any(n => n._Status == EntityStatus.Active))
             return true;
     }
     else if(intendedStatus == EntityStatus.Deleted)
     {
         if (commodity.CommodityGrades.Any(n => n._Status != EntityStatus.Deleted))
             return true;
     }
     return false;
 }
      private async Task<ImportValidationResultInfo> ValidateCommodityAsync(Commodity commodity)
      {
          return await Task.Run(() =>
          {
              var res = _commodityRepository.Validate(commodity);
              return new ImportValidationResultInfo()
              {
                  Results = res.Results,
                  // Description = "Row-" + count,
                  Entity = commodity
              };
          });

      } 
Example #7
0
 protected Guid AddCommodity(string name, string code, Guid commodityTypeid)
 {
     Commodity comm = new Commodity(Guid.NewGuid())
                          {
                              Name = name,
                              Code = code,
                              Description = name,
                              _Status = EntityStatus.Active,
                               CommodityType = _commodityTypeRepository.GetById(commodityTypeid)
                          };
     comm.CommodityGrades = AddCommodityGrades(comm);
     return _commodityRepository.Save(comm);
 }
Example #8
0
        List<CommodityGrade> AddCommodityGrades(Commodity comm)
        {
            List<CommodityGrade> grades = new List<CommodityGrade>();
            CommodityGrade grade = new CommodityGrade(Guid.NewGuid())
                                       {
                                           Code = comm.Code + " A",
                                           Description = comm.Name + " Grade A",
                                           Name = comm.Name + " Grade A",
                                           Commodity = comm,
                                           UsageTypeId = 1,
                                           _Status = EntityStatus.Active,

                                       };
            grades.Add(grade);
            CommodityGrade grade2 = new CommodityGrade(Guid.NewGuid())
            {
                Code = comm.Code +" B",
                Description = comm.Name +" Grade B",
                Name = comm.Name + " Grade B",
                Commodity = comm,
                UsageTypeId = 1,
                _Status = EntityStatus.Active,

            };
            grades.Add(grade2);
            CommodityGrade grade3 = new CommodityGrade(Guid.NewGuid())
            {
                Code = comm.Code + " C",
                Description = comm.Name + " Grade C",
                Name = comm.Name + " Grade C",
                Commodity = comm,
                UsageTypeId = 1,
                _Status = EntityStatus.Active,

            };
            grades.Add(grade3);

            return grades;
        }
 private ValidationResultInfo Validate(Commodity commodity)
 {
     return _commodityRepository.Validate(commodity);
 }
        void ClearViewModel()
        {

            DocumentReference = string.Empty;
            Notes = "";
            SelectedAccountName = "--Select Account---"; ;
            SelectedFarmerName = "--Select Farmer---";
            DocumentId = Guid.Empty;
            SelectedAccount = new CommoditySupplier(Guid.Empty) { AccountName = "--Select Account---" };
            SelectedFarmer = new CommodityOwner(Guid.Empty) { FirstName = "--Select Farmer---" };
            DocumentIssuerUser = null;
            DocumentParentId = Guid.Empty;
            SelectedCommodity = new Commodity(Guid.Empty) { Name = "--Select Commodity---" }; ;
            SelectedGrade = new CommodityGrade(Guid.Empty) { Name = "--Select Grade---" };
            DocumentIssuerCostCentre = null;
            DocumentRecipientCostCentre = null;
            DriverName = "";
            RegistrationNumber = "";
            Weight = decimal.Zero;
            LineItems.Clear();
            FarmersList.Clear();
            CommodityList.Clear();
            GradeList.Clear();
            FarmerVisibility = "Collapsed";
            WeighTypeProp = WeighType.Manual;
            // MakeWeightextBoxReadOnly = false;
        }
        private void SelectCommodity()
        {
            using (var container = NestedContainer)
            {
                var selected = Using<IAgriItemsLookUp>(container).SelectCommodity();

                SelectedCommodity = selected;
                if (selected == null)
                {
                    SelectedCommodity = new Commodity(Guid.Empty) { Name = "--Select Commodity---" };
                }
                LoadGrades();
            }
        }