Example #1
0
        public MA_COUNTRY_LIMIT CreateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Effective date cannot be set to past date.");

                if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");

                if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE)
                    throw this.CreateException(new Exception(), "Expiry date must be after effective date.");

                var duplicate = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ISTEMP == true && p.ISACTIVE == true
                                                                                                && p.COUNTRY_ID == record.COUNTRY_ID && p.EXPIRY_DATE >= record.EFFECTIVE_DATE);
                if (duplicate != null)
                    throw this.CreateException(new Exception(), "Duplicate temp limit info");

                LogBusiness logBusiness = new LogBusiness();
                var newRecord = new { AMOUNT = record.AMOUNT, EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE };
                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, record.COUNTRY_ID, LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY_LIMIT, "Temp Country Limit", newRecord));

                unitOfWork.MA_COUNTRY_LIMITRepository.Add(record);
                unitOfWork.Commit();
            }

            return record;
        }
Example #2
0
        public MA_COUNTRY Create(SessionInfo sessioninfo, MA_COUNTRY country)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate1 = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.LABEL == country.LABEL);
                if (checkDuplicate1 != null)
                    throw this.CreateException(new Exception(), "Short name is duplicated");

                //Prepare Country-Limit data
                MA_COUNTRY_LIMIT ctLimit = new MA_COUNTRY_LIMIT();

                ctLimit.ID = Guid.NewGuid();
                ctLimit.COUNTRY_ID = country.ID;
                ctLimit.AMOUNT = 0;
                ctLimit.EFFECTIVE_DATE = sessioninfo.Process.CurrentDate;
                ctLimit.EXPIRY_DATE = sessioninfo.Process.CurrentDate;
                ctLimit.ISACTIVE = true;
                ctLimit.ISTEMP = false;
                ctLimit.FLAG_CONTROL = true;
                ctLimit.LOG.INSERTDATE = DateTime.Now;
                ctLimit.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

                unitOfWork.MA_COUNTRYRepository.Add(country);
                unitOfWork.MA_COUNTRY_LIMITRepository.Add(ctLimit);
                unitOfWork.Commit();
            }

            return country;
        }
Example #3
0
        public static object CreateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();

                record.ID = Guid.NewGuid();
                record.ISTEMP = true;
                record.FLAG_CONTROL = true;
                record.LOG.INSERTDATE = DateTime.Now;
                record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

                var addedRecord = _countryBusiness.CreateTempLimit(sessioninfo, record);

                return new { Result = "OK", Record = addedRecord };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
Example #4
0
        public static object UpdateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();
                record.LOG.MODIFYDATE = DateTime.Now;
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;

                var updateRecord = _countryBusiness.UpdateTempCountryLimit(sessioninfo, record);

                return new { Result = "OK", Record = updateRecord };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
Example #5
0
        public static object UpdateCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            try
            {
                CountryBusiness _countryBusiness = new CountryBusiness();

                if (!record.FLAG_CONTROL)
                {
                    record.AMOUNT = 0;
                    record.EFFECTIVE_DATE = sessioninfo.Process.CurrentDate;
                    record.EXPIRY_DATE = sessioninfo.Process.CurrentDate;
                }

                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE = DateTime.Now;

                var updateRecord = _countryBusiness.UpdateCountryLimit(sessioninfo, record);

                return new { Result = "OK" , Record = updateRecord };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
Example #6
0
        public MA_COUNTRY_LIMIT UpdateTempCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT countryLimit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (countryLimit.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Effective date cannot be set to past date.");

                if (countryLimit.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");

                if (countryLimit.EXPIRY_DATE <= countryLimit.EFFECTIVE_DATE)
                    throw this.CreateException(new Exception(), "Expiry date must be after effective date.");

                var duplicate = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID != countryLimit.ID && p.ISTEMP == true && p.ISACTIVE == true
                                                                                                && p.COUNTRY_ID == countryLimit.COUNTRY_ID && p.EXPIRY_DATE >= countryLimit.EFFECTIVE_DATE);
                if (duplicate != null)
                    throw this.CreateException(new Exception(), "Duplicate temp limit info");

                var foundData = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID == countryLimit.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    LogBusiness logBusiness = new LogBusiness();
                    var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = foundData.EFFECTIVE_DATE, EXPIRE_DATE = foundData.EXPIRY_DATE, ISACTIVE = foundData.ISACTIVE };
                    var newRecord = new { AMOUNT = countryLimit.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = countryLimit.EFFECTIVE_DATE, EXPIRE_DATE = countryLimit.EXPIRY_DATE, ISACTIVE = countryLimit.ISACTIVE };
                    var log = logBusiness.UpdateLogging(sessioninfo, foundData.COUNTRY_ID, LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY_LIMIT, oldRecord, newRecord, "Temp Country Limit");
                    if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);

                    foundData.AMOUNT = countryLimit.AMOUNT;
                    foundData.ISACTIVE = countryLimit.ISACTIVE;
                    foundData.EFFECTIVE_DATE = countryLimit.EFFECTIVE_DATE;
                    foundData.EXPIRY_DATE = countryLimit.EXPIRY_DATE;
                    foundData.LOG.MODIFYBYUSERID = countryLimit.LOG.MODIFYBYUSERID;
                    foundData.LOG.MODIFYDATE = countryLimit.LOG.MODIFYDATE;

                    unitOfWork.Commit();
                }
            }

            return countryLimit;
        }
Example #7
0
        public MA_COUNTRY_LIMIT UpdateCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT countryLimit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (countryLimit.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");

                var foundData = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID == countryLimit.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    LogBusiness logBusiness = new LogBusiness();
                    var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EXPIRE_DATE = foundData.EXPIRY_DATE };
                    var newRecord = new { AMOUNT = countryLimit.AMOUNT.ToString("#,##0"), EXPIRE_DATE = countryLimit.EXPIRY_DATE };
                    var log = logBusiness.UpdateLogging(sessioninfo, foundData.COUNTRY_ID, LimitLogEvent.COUNTRY_LIMIY_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY, oldRecord, newRecord, "Country Limit");
                    if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);

                    foundData.AMOUNT = countryLimit.AMOUNT;
                    foundData.FLAG_CONTROL = countryLimit.FLAG_CONTROL;
                    foundData.EXPIRY_DATE = countryLimit.EXPIRY_DATE;
                    foundData.LOG.MODIFYBYUSERID = countryLimit.LOG.MODIFYBYUSERID;
                    foundData.LOG.MODIFYDATE = countryLimit.LOG.MODIFYDATE;

                    unitOfWork.Commit();
                }
            }

            return countryLimit;
        }
 public static object UpdateTempCountry(MA_COUNTRY_LIMIT record)
 {
     return CountryUIP.UpdateTempLimit(SessionInfo, record);
 }