Ejemplo n.º 1
0
        /// <summary>
        /// This method is used to save bank details based on subsite id
        /// </summary>
        /// <param name="sbDto"></param>
        /// <param name="SubSiteID"></param>
        /// <param name="RefID"></param>
        /// <returns></returns>
        public bool SaveBankDetail(List <SubSiteBankFeesDTO> sbDto, Guid SubSiteID, Guid RefID, Guid UserId)
        {
            bool iretval = false;

            try
            {
                foreach (var it in sbDto)
                {
                    Guid newGenId = Guid.NewGuid();
                    SubSiteBankFeesConfig subsitebankfeesconfig = new SubSiteBankFeesConfig();
                    subsitebankfeesconfig.ID = newGenId;
                    subsitebankfeesconfig.emp_CustomerInformation_ID = RefID;
                    subsitebankfeesconfig.BankMaster_ID        = new Guid(it.BankMaster_ID);
                    subsitebankfeesconfig.BankMaxFees          = it.BankMaxFees;
                    subsitebankfeesconfig.BankMaxFees_MSO      = it.BankMaxFees_MSO;
                    subsitebankfeesconfig.ServiceOrTransmitter = it.ServiceorTransmission;
                    subsitebankfeesconfig.SubSiteFeeConfig_ID  = SubSiteID;

                    subsitebankfeesconfig.CreatedBy       = UserId;
                    subsitebankfeesconfig.CreatedDate     = DateTime.Now;
                    subsitebankfeesconfig.LastUpdatedBy   = UserId;
                    subsitebankfeesconfig.LastUpdatedDate = DateTime.Now;

                    db.SubSiteBankFeesConfigs.Add(subsitebankfeesconfig);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/SaveBankDetail", Guid.Empty);
                return(false);
            }
            return(iretval);
        }
        /// <summary>
        /// This method is used to save and update the sub site bank fee configuration
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int SaveSubSiteBankFeeConfig(List <SubSiteBankFeeConfigDTO> dto)
        {
            int  entityState = 0;
            Guid refId = Guid.Empty, bankId;
            int  SvbOrTrans             = 0;
            SubSiteBankFeesConfig model = new SubSiteBankFeesConfig();
            int check = 0;

            if (dto != null)
            {
                foreach (SubSiteBankFeeConfigDTO item in dto)
                {
                    if (item.ServiceorTransmitter != 0)
                    {
                        bool IsRefId = Guid.TryParse(item.RefId, out refId);

                        if (!IsRefId)
                        {
                            return(-1);
                        }

                        if (check == 0)
                        {
                            check = 1;
                            var result = db.SubSiteBankFeesConfigs.Where(a => a.emp_CustomerInformation_ID == refId).ToList();

                            if (result.Count() > 0)
                            {
                                db.SubSiteBankFeesConfigs.RemoveRange(result);
                                db.SaveChanges();
                            }
                        }

                        bool Isbankid = Guid.TryParse(item.BankID, out bankId);
                        if (!Isbankid)
                        {
                            return(-1);
                        }

                        SvbOrTrans = item.ServiceorTransmitter;

                        // model = db.SubSiteBankFeesConfigs.Where(a => a.BankMaster_ID == bankId && a.emp_CustomerInformation_ID == refId && a.ServiceOrTransmitter == item.ServiceorTransmitter).FirstOrDefault();

                        //if (model != null)
                        //{
                        //    entityState = (int)System.Data.Entity.EntityState.Modified;
                        //}
                        //else
                        //{
                        model       = new SubSiteBankFeesConfig();
                        model.ID    = Guid.NewGuid();
                        entityState = (int)System.Data.Entity.EntityState.Added;
                        //}

                        model.emp_CustomerInformation_ID = refId;
                        model.BankMaster_ID        = new Guid(item.BankID);
                        model.ServiceOrTransmitter = item.ServiceorTransmitter;
                        model.BankMaxFees          = item.AmountDSK;
                        model.BankMaxFees_MSO      = item.AmountMSO;
                        // model.AmountType = item.AmountType;
                        Guid Questionid;
                        if (!Guid.TryParse(item.QuestionID, out Questionid))
                        {
                            Questionid = Guid.Empty;
                        }
                        model.QuestionID      = Questionid;
                        model.LastUpdatedBy   = item.UserId ?? Guid.Empty;
                        model.LastUpdatedDate = System.DateTime.Now;

                        if (entityState == (int)System.Data.Entity.EntityState.Added)
                        {
                            model.CreatedBy   = item.UserId ?? Guid.Empty;
                            model.CreatedDate = System.DateTime.Now;
                            db.SubSiteBankFeesConfigs.Add(model);
                        }
                        else
                        {
                            db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }
            }

            try
            {
                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    db.SaveChanges();
                }
                db.Dispose();

                return(1);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/SaveSubSiteBankFeeConfig", Guid.Empty);
                return(0);

                throw;
            }
        }