예제 #1
0
 public NewNPPBKCViewModel.NewNppbckDetails MapToModel(CustomService.Data.MASTER_NPPBKC nppbkc)
 {
     try
     {
         return(new NewNPPBKCViewModel.NewNppbckDetails()
         {
             VirtualNppbckId = nppbkc.NPPBKC_ID,
             Address1 = nppbkc.ADDR1,
             Address2 = nppbkc.ADDR2,
             City = nppbkc.CITY,
             CityAlias = nppbkc.CITY_ALIAS,
             KppbcId = nppbkc.KPPBC_ID,
             KppbcAddress = nppbkc.KPPBC_ADDRESS,
             Region = nppbkc.REGION,
             RegionOfficeOfDGCE = nppbkc.REGION_DGCE,
             AcountNumber = (nppbkc.VENDORS != null) ? nppbkc.VENDORS.LIFNR : null,
             TextTo = nppbkc.TEXT_TO,
             StartDate = nppbkc.START_DATE,
             EndDate = nppbkc.END_DATE,
             CreatedBy = nppbkc.CREATED_BY,
             CreateDate = nppbkc.CREATED_DATE,
             ModifiedBy = nppbkc.MODIFIED_BY,
             ModifiedDate = nppbkc.MODIFIED_DATE,
             DgceAddress = nppbkc.DGCE_ADDRESS,
             Location = nppbkc.LOCATION,
             FlagForLack1 = (nppbkc.FLAG_FOR_LACK1 != null) ? nppbkc.FLAG_FOR_LACK1.Value : false,
             Is_Deleted = (nppbkc.IS_DELETED != null) ? ((nppbkc.IS_DELETED.Value) ? "Yes" : "No") : "No"
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        private List <CustomService.Data.CHANGES_HISTORY> SetChanges(NewNPPBKCViewModel.NewNppbckDetails origin, CustomService.Data.MASTER_NPPBKC nppbkc)
        {
            var changeList = new Dictionary <string, string[]>();

            PlaceValues("NPPBKC_ID", origin.VirtualNppbckId, nppbkc.NPPBKC_ID, ref changeList);
            PlaceValues("ADDR1", origin.Address1, nppbkc.ADDR1, ref changeList);
            PlaceValues("ADDR2", origin.Address2, nppbkc.ADDR2, ref changeList);
            PlaceValues("KPPBC_ID", origin.KppbcId, nppbkc.KPPBC_ID, ref changeList);
            PlaceValues("KPPBC_ADDRESS", origin.KppbcAddress, nppbkc.KPPBC_ADDRESS, ref changeList);
            PlaceValues("DGCE_ADDRESS", origin.DgceAddress, nppbkc.DGCE_ADDRESS, ref changeList);
            PlaceValues("CITY", origin.City, nppbkc.CITY, ref changeList);
            PlaceValues("CITY_ALIAS", origin.CityAlias, nppbkc.CITY_ALIAS, ref changeList);
            PlaceValues("REGION", origin.Region, nppbkc.REGION, ref changeList);
            PlaceValues("REGION_DGCE", origin.RegionOfficeOfDGCE, nppbkc.REGION_DGCE, ref changeList);
            PlaceValues("TEXT_TO", origin.TextTo, nppbkc.TEXT_TO, ref changeList);
            PlaceValues("LOCATION", origin.Location, nppbkc.LOCATION, ref changeList);
            PlaceValues("FLAG_FOR_LACK1", origin.FlagForLack1 ? "True" : "False", nppbkc.FLAG_FOR_LACK1 != null ? (nppbkc.FLAG_FOR_LACK1.Value ? "True" : "False") : "False", ref changeList);
            if (nppbkc.START_DATE != null)
            {
                var newVal = (origin.StartDate.HasValue) ? origin.StartDate.Value.ToString("dd MMMM yyyy") : null;
                PlaceValues("START_DATE", newVal, nppbkc.START_DATE.Value.ToString("dd MMMM yyyy"), ref changeList);
            }

            if (nppbkc.END_DATE != null)
            {
                var newVal = (origin.EndDate.HasValue) ? origin.EndDate.Value.ToString("dd MMMM yyyy") : null;
                PlaceValues("END_DATE", newVal, nppbkc.END_DATE.Value.ToString("dd MMMM yyyy"), ref changeList);
            }

            if (nppbkc.VENDORS != null)
            {
                PlaceValues("ACCOUNT_NUMBER", origin.AcountNumber, nppbkc.VENDORS.LIFNR, ref changeList);
            }
            List <CustomService.Data.CHANGES_HISTORY> changeLogs = new List <CustomService.Data.CHANGES_HISTORY>();

            foreach (var changed in changeList)
            {
                var changes = new CustomService.Data.CHANGES_HISTORY();
                changes.FORM_TYPE_ID  = (int)Enums.MenuList.NPPBKC;
                changes.FORM_ID       = nppbkc.NPPBKC_ID;
                changes.FIELD_NAME    = changed.Key;
                changes.MODIFIED_BY   = CurrentUser.USER_ID;
                changes.MODIFIED_DATE = DateTime.Now;
                changes.OLD_VALUE     = changed.Value[0];
                changes.NEW_VALUE     = changed.Value[1];
                changeLogs.Add(changes);
            }
            return(changeLogs);
        }