Esempio n. 1
0
        public MA_LIMIT UpdateLimit(SessionInfo sessioninfo, MA_LIMIT limit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_LIMITRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(limit.LABEL.ToLower()) && p.ID != limit.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                var foundLimit = unitOfWork.MA_LIMITRepository.All().FirstOrDefault(p => p.ID == limit.ID);
                if (foundLimit == null)
                {
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                }
                else
                {
                    foundLimit.ID       = limit.ID;
                    foundLimit.LABEL    = limit.LABEL;
                    foundLimit.ISACTIVE = limit.ISACTIVE;
                    foundLimit.INDEX    = limit.INDEX;

                    unitOfWork.Commit();
                }
            }

            return(limit);
        }
Esempio n. 2
0
        public MA_LIMIT CreateLimit(SessionInfo sessioninfo, MA_LIMIT limit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_LIMITRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(limit.LABEL.ToLower()));
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                unitOfWork.MA_LIMITRepository.Add(limit);
                unitOfWork.Commit();
            }

            return(limit);
        }
Esempio n. 3
0
 public static object UpdateLimit(SessionInfo sessioninfo, MA_LIMIT record)
 {
     try
     {
         LookupBusiness _lookupbusiness = new LookupBusiness();
         record.ISACTIVE   = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
         record.LABEL      = record.LABEL;
         record.LIMIT_TYPE = record.LIMIT_TYPE;
         record.INDEX      = record.INDEX;
         var updated = _lookupbusiness.UpdateLimit(sessioninfo, record);
         return(new { Result = "OK" });
     }
     catch (Exception ex)
     {
         return(new { Result = "ERROR", Message = ex.Message });
     }
 }
Esempio n. 4
0
        public List <LimitCheckModel> GetPCEReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strLimit, string strSource, string strStatus)
        {
            try
            {
                DateTime             dteReport;
                LimitCheckBusiness   _limitBusiness        = new LimitCheckBusiness();
                DealBusiness         _dealBusiness         = new DealBusiness();
                CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
                Guid guCtpyID  = Guid.Empty;
                Guid guLimitID = Guid.Empty;

                if (String.IsNullOrEmpty(strReportDate))
                {
                    throw this.CreateException(new Exception(), "Please input report date.");
                }
                else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport))
                {
                    throw this.CreateException(new Exception(), "Invalid report date.");
                }
                else
                {
                    dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null);
                }

                if (Guid.TryParse(strCtpy, out guCtpyID))
                {
                    guCtpyID = Guid.Parse(strCtpy);
                }

                if (_dealBusiness.CountByProcessDate(dteReport) == 0)
                {
                    throw this.CreateException(new Exception(), "No data for selected report date.");
                }

                var limits = _limitBusiness.GetPCEByCriteria(dteReport, guCtpyID, Guid.Empty, strSource, Guid.Empty, Guid.Empty).Distinct(new LimitCheckComparer()).AsQueryable();

                //Get temp limit
                //Look for temp limit when all conditions meet
                // 1. Transaction maturity date <= Temp limit maturity date
                foreach (LimitCheckModel limit in limits)
                {
                    MA_TEMP_CTPY_LIMIT temp_limit = _counterpartyBusiness.GetActiveTempByID(sessioninfo.Process.CurrentDate, sessioninfo.Process.CurrentDate, limit.CTPY_LIMIT_ID);

                    if (temp_limit != null)
                    {
                        limit.TEMP_AMOUNT = temp_limit.AMOUNT;
                    }
                }

                //Additional filter on limit name
                if (Guid.TryParse(strLimit, out guLimitID))
                {
                    LookupBusiness _lookupBusiness = new LookupBusiness();
                    MA_LIMIT       limit           = _lookupBusiness.GetLimitAll().FirstOrDefault(t => t.ID == Guid.Parse(strLimit));

                    limits = limits.Where(t => t.LIMIT_LABEL.IndexOf(limit.LABEL, StringComparison.OrdinalIgnoreCase) >= 0);
                }

                if (strStatus != "")
                {
                    limits = limits.Where(t => t.STATUS.IndexOf(strStatus, StringComparison.OrdinalIgnoreCase) >= 0);
                }

                return(limits.ToList());
            }

            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Esempio n. 5
0
 public static object Update(MA_LIMIT record)
 {
     return(LookupUIP.UpdateLimit(SessionInfo, record));
 }