Ejemplo n.º 1
0
        public object Save([FromBody] TblDisburseCompanyInfo tblDisburseCompanyInfo)
        {
            try
            {
                tblDisburseCompanyInfo.CompanyId = Convert.ToInt16(_disbursementService.GetMaxCompanyId()) + 1;
                _disbursementService.Add(tblDisburseCompanyInfo);

                //Insert into audit trial audit and detail
                _auditTrailService.InsertModelToAuditTrail(tblDisburseCompanyInfo, tblDisburseCompanyInfo.entry_user, 10, 3, "Disbursement Company", tblDisburseCompanyInfo.CompanyId.ToString(), "Saved Successfully!");
            }
            catch (Exception ex)
            {
                return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
            }

            return(true);
        }
        public object Save([FromBody] ApplicationUser model)
        {
            try
            {
                if (model.Id != 0)
                {
                    ApplicationUser prevModel = usersService.SingleOrDefault(model.Id, new ApplicationUser());
                    model.UpdatedDate = DateTime.Now;
                    usersService.Update(model);

                    //Insert into audit trial audit and detail

                    //ApplicationUser prevModel = usersService.SingleOrDefault(model.Id, new ApplicationUser());
                    //prevModel.Status = "default";//insert for only audit trail
                    _auditTrailService.InsertUpdatedModelToAuditTrail(model, prevModel, model.UpdatedBy, 7, 4, "Application User", model.Username, "Updated Successfully!");

                    return(model);
                }
                else
                {
                    model = generateSecuredCredentials(model);
                    model = usersService.Add(model);

                    string messagePrefix = ", Your Account Has been Created on OK Wallet Admin Application. Your username is " + model.Username + " and password is " + model.PlainPassword;

                    MessageModel messageModel = new MessageModel()
                    {
                        Mphone      = model.MobileNo,
                        MessageId   = "999",
                        MessageBody = "Dear " + model.Name + messagePrefix + ". Thank you."
                    };

                    MessageService messageService = new MessageService();
                    messageService.SendMessage(messageModel);

                    //Insert into audit trial audit and detail
                    _auditTrailService.InsertModelToAuditTrail(model, model.CreatedBy, 7, 3, "Application User", model.Username, "Saved Successfully!");

                    return(model);
                }
            }
            catch (Exception ex)
            {
                return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
            }
        }
 public object ExecuteEOD(string todayDate, string userName)
 {
     try
     {
         string         response = null;
         DateRangeModel date     = new DateRangeModel();
         date.FromDate = string.IsNullOrEmpty(todayDate) == true ? DateTime.Now : DateTime.Parse(todayDate);
         response      = transMastService.ExecuteEOD(date.FromDate, userName).ToString();
         //Insert into audit trial audit and detail
         var model = new { todayDate, userName };
         _auditTrailService.InsertModelToAuditTrail(model, userName, 10, 4, "End of Day (EOD)", date.FromDate.ToString(), response);
         return(response);
     }
     catch (Exception ex)
     {
         return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
     }
 }
        public object Save(bool isEditMode, string evnt, [FromBody] TblCashEntry cashEntry)
        {
            try
            {
                if (isEditMode != true)
                {
                    try
                    {
                        cashEntry.Status    = "";
                        cashEntry.TransNo   = _distributorDepositService.GetTransactionNo();
                        cashEntry.TransDate = System.DateTime.Now;
                        _distributorDepositService.Add(cashEntry);

                        //Insert into audit trial audit and detail
                        cashEntry.Status = "default";//insert for only audit trail
                        _auditTrailService.InsertModelToAuditTrail(cashEntry, cashEntry.CreateUser, 9, 3, "Distributor Deposit", cashEntry.AcNo, "Saved Successfully!");
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                    return(true);
                }
                else
                {
                    if (evnt == "edit")
                    {
                        try
                        {
                            cashEntry.Status     = "";
                            cashEntry.UpdateDate = System.DateTime.Now;
                            _distributorDepositService.UpdateByStringField(cashEntry, "TransNo");

                            //Insert into audit trial audit and detail
                            cashEntry.Status = "default"; //insert for only audit trail
                            TblCashEntry prevModel = _distributorDepositService.GetDestributorDepositByTransNo(cashEntry.TransNo);
                            prevModel.Status = "default"; //insert for only audit trail
                            _auditTrailService.InsertUpdatedModelToAuditTrail(cashEntry, prevModel, cashEntry.UpdateUser, 9, 4, "Distributor Deposit", cashEntry.AcNo, "Updated Successfully!");
                        }
                        catch (Exception ex)
                        {
                            throw;
                        }

                        return(true);
                    }
                    else if (evnt == "register")
                    {
                        cashEntry.Status      = "P";
                        cashEntry.CheckedDate = System.DateTime.Now;

                        //insert into gl_trans_dtl and gl_trans_mst and RegInfo
                        var successOrErrorMsg = _distributorDepositService.DataInsertToTransMSTandDTL(cashEntry);

                        //Insert into audit trial audit and detail
                        TblCashEntry prevModel = _distributorDepositService.GetDestributorDepositByTransNo(cashEntry.TransNo);
                        prevModel.Status      = "default";//insert for only audit trail
                        prevModel.CheckedUser = "";
                        _auditTrailService.InsertUpdatedModelToAuditTrail(cashEntry, prevModel, cashEntry.CheckedUser, 9, 4, "Distributor Deposit", cashEntry.AcNo, "Approved Successfully!");


                        return(successOrErrorMsg);
                    }
                    else
                    {
                        cashEntry.Status      = "M";// M means pass to maker
                        cashEntry.CheckedDate = System.DateTime.Now;
                        _distributorDepositService.UpdateByStringField(cashEntry, "TransNo");

                        //Insert into audit trial audit and detail
                        TblCashEntry prevModel = _distributorDepositService.GetDestributorDepositByTransNo(cashEntry.TransNo);
                        prevModel.Status      = "default";//insert for only audit trail
                        prevModel.CheckedUser = "";
                        _auditTrailService.InsertUpdatedModelToAuditTrail(cashEntry, prevModel, cashEntry.CheckedUser, 9, 4, "Distributor Deposit", cashEntry.AcNo, "Pass to Maker Successfully!");

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
            }
        }
        public async Task <object> ConfirmBill([FromBody] BillCollectionCommon objBillCollectionCommon)
        {
            try
            {
                using (var httpClient = new HttpClient())
                {
                    string[] param = new string[9];
                    param[0] = "PAY";
                    if (objBillCollectionCommon.MethodName.Contains("."))
                    {
                        param[1] = objBillCollectionCommon.MethodName + objBillCollectionCommon.SubMenuId;
                    }
                    else
                    {
                        param[1] = objBillCollectionCommon.MethodName;
                    }

                    param[2] = objBillCollectionCommon.BillId;
                    param[3] = objBillCollectionCommon.bill2;
                    param[4] = "M";
                    param[5] = objBillCollectionCommon.Amount.ToString();
                    param[6] = "5555";
                    param[7] = objBillCollectionCommon.BeneficiaryNumber;
                    param[8] = "";


                    List <BillApiCalling> billApiCallingList = new List <BillApiCalling>();
                    BillApiCalling        objBillApiCalling  = new BillApiCalling();
                    //objBillApiCalling.appid = "payapicall";
                    //objBillApiCalling.appchk = "589500e2dd1a2d985901cca01205aaba";
                    //for live
                    //objBillApiCalling.appid = "payapiLIVEcall";
                    //objBillApiCalling.appchk = "4945bdda77eba2bd6fa38add869a08d0";
                    objBillApiCalling.call   = "msgin";
                    objBillApiCalling.mphone = "BP";
                    objBillApiCalling.parts  = param;


                    string json          = JsonConvert.SerializeObject(objBillApiCalling);
                    string base64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(json));

                    HttpContent httpContent = new StringContent(base64Encoded, Encoding.UTF8);
                    //HttpContent httpContent = new StringContent(JsonConvert.SerializeObject(telemetry), Encoding.UTF8);
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");


                    BillApiInfo apiInfo                = new BillApiInfo();
                    dynamic     apiResponse            = null;
                    BillCollectionCheckResponse result = new BillCollectionCheckResponse();
                    using (var response = await httpClient.PostAsync(apiInfo.Ip + apiInfo.ApiUrl, httpContent))
                    {
                        apiResponse = await response.Content.ReadAsStringAsync();

                        byte[] data          = Convert.FromBase64String(apiResponse);
                        string decodedString = Encoding.UTF8.GetString(data);
                        result = JsonConvert.DeserializeObject <BillCollectionCheckResponse>(decodedString);
                    }


                    //Insert into audit trial audit and detail
                    _auditTrailService.InsertModelToAuditTrail(objBillCollectionCommon, objBillCollectionCommon.EntryUser, objBillCollectionCommon.ParentPenuId, 3, objBillCollectionCommon.Title, objBillCollectionCommon.BillId, result.msg);



                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, ex.ToString()));
            }
        }
        public string UploadExcel(int organizationId, string batchno, string makerId, double amount)
        {
            string message             = "";
            HttpResponseMessage result = null;
            var httpRequest            = HttpContext.Current.Request;

            if (httpRequest.Files.Count > 0)
            {
                HttpPostedFile file   = httpRequest.Files[0];
                Stream         stream = file.InputStream;

                IExcelDataReader reader = null;

                if (file.FileName.EndsWith(".xls"))
                {
                    reader = ExcelReaderFactory.CreateBinaryReader(stream);
                }
                else if (file.FileName.EndsWith(".xlsx"))
                {
                    reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                }
                else
                {
                    message = "This file format is not supported";
                }

                DataSet excelRecords = reader.AsDataSet();
                reader.Close();

                var finalRecords = excelRecords.Tables[0];

                bool   isUploaded    = false;
                int    lastRow       = finalRecords.Rows.Count - 1;
                double disburseTotal = Convert.ToDouble(finalRecords.Rows[lastRow][2]);
                if (disburseTotal > 0)
                {
                    if (disburseTotal > amount)
                    {
                        isUploaded = false;
                        message    = "Disbursed total amount is greater than company total.";
                    }
                    else
                    {
                        for (int i = 1; i < finalRecords.Rows.Count - 1; i++)
                        {
                            TblDisburseTmp objTblDisburseTmp = new TblDisburseTmp();
                            objTblDisburseTmp.AcNo           = finalRecords.Rows[i][1].ToString().Trim();
                            objTblDisburseTmp.Amount         = Convert.ToDouble(finalRecords.Rows[i][2]);
                            objTblDisburseTmp.MakerId        = makerId.ToString();
                            objTblDisburseTmp.Batchno        = batchno.ToString();
                            objTblDisburseTmp.Sl             = Convert.ToInt16(finalRecords.Rows[i][0]);
                            objTblDisburseTmp.OrganizationId = organizationId;

                            _TblDisburseTmpService.Add(objTblDisburseTmp);
                        }
                        isUploaded = true;
                        if (isUploaded)
                        {
                            message = "Excel file has been successfully uploaded";
                            //Insert into audit trial audit and detail
                            CompanyDisbursementUpload objCompanyDisbursementUpload = new CompanyDisbursementUpload();
                            objCompanyDisbursementUpload.CompanyId = organizationId;
                            objCompanyDisbursementUpload.BatchNo   = batchno;
                            objCompanyDisbursementUpload.MakerId   = makerId;
                            _auditTrailService.InsertModelToAuditTrail(objCompanyDisbursementUpload, objCompanyDisbursementUpload.MakerId, 10, 3, "Disbursement Process", objCompanyDisbursementUpload.CompanyId.ToString(), "Uploaded Successfully!");
                        }
                        else
                        {
                            message = "Excel file uploaded has fiald";
                        }
                    }
                }
                else
                {
                    message = "Disbursed total amount must be greater than 0.";
                }
            }

            else
            {
                result = Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            return(message);
        }
Ejemplo n.º 7
0
        public object Save([FromBody] DisbursementUser model)
        {
            try
            {
                if (model.Id != 0)
                {
                    //DisbursementUser prevModel = disbursementUserService.SingleOrDefault(model.Id, new DisbursementUser());
                    //model.UpdatedDate = DateTime.Now;
                    //disbursementUserService.Update(model);

                    ////Insert into audit trial audit and detail
                    //_auditTrailService.InsertUpdatedModelToAuditTrail(model, prevModel, model.UpdatedBy, 7, 4, "Application User", model.Username, "Updated Successfully!");

                    //return model;

                    if (string.IsNullOrEmpty(model.PlainPassword))
                    {
                        return(disbursementUserService.Update(model));
                    }
                    else
                    {
                        //model = generateSecuredCredentials(model);
                        disbursementUserService.Update(model);
                        return(HttpStatusCode.OK);
                    }
                }
                else
                {
                    model = generateSecuredCredentials(model);
                    model = disbursementUserService.Add(model);

                    if (!string.IsNullOrEmpty(model.MobileNo))
                    {
                        string messagePrefix = ", Your Account Has been Created on OK Wallet Admin Application. Your username is " + model.Username + " and password is " + model.PlainPassword;

                        MessageModel messageModel = new MessageModel()
                        {
                            Mphone      = model.MobileNo,
                            MessageId   = "999",
                            MessageBody = "Dear " + model.Name + messagePrefix + ". Thank you."
                        };

                        MessageService messageService = new MessageService();
                        messageService.SendMessage(messageModel);

                        //Insert into audit trial audit and detail
                        _auditTrailService.InsertModelToAuditTrail(model, model.CreatedBy, 7, 3, "Disbursement User", model.Username, "Saved Successfully!");

                        return(HttpStatusCode.OK);
                    }
                    else
                    {
                        return(HttpStatusCode.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString());
                return(HttpStatusCode.BadRequest);
            }
        }
Ejemplo n.º 8
0
        public object SaveCommissionConversion(bool isEditMode, string evnt, [FromBody] TblCommissionConversion tblCommissionConversion)
        {
            try
            {
                if (isEditMode != true)
                {
                    try
                    {
                        tblCommissionConversion.Status     = "";
                        tblCommissionConversion.TransNo    = _CommissionConversionService.GetTransactionNo();
                        tblCommissionConversion.CreateDate = System.DateTime.Now;
                        //_CommissionConversionService.Add(tblCommissionConversion);
                        _CommissionConversionService.AddBySP(tblCommissionConversion);

                        //Insert into audit trial audit and detail
                        tblCommissionConversion.Status = "default";//insert for only audit trail
                        _auditTrailService.InsertModelToAuditTrail(tblCommissionConversion, tblCommissionConversion.CreateUser, 9, 3, "Distributor Deposit", tblCommissionConversion.Mphone, "Saved Successfully!");
                    }
                    catch (Exception)
                    {
                        throw;
                    }

                    return(true);
                }
                else
                {
                    //if (evnt == "edit")
                    //{
                    //    try
                    //    {
                    //        tblCommissionConversion.Status = "";
                    //        _CommissionConversionService.UpdateByStringField(tblCommissionConversion, "TransNo");

                    //        //Insert into audit trial audit and detail
                    //        tblCommissionConversion.Status = "default";//insert for only audit trail
                    //        TblCashEntry prevModel = _CommissionConversionService.GetDestributorDepositByTransNo(tblCommissionConversion.TransNo);
                    //        prevModel.Status = "default";//insert for only audit trail
                    //        _auditTrailService.InsertUpdatedModelToAuditTrail(tblCommissionConversion, prevModel, tblCommissionConversion.UpdateUser, 9, 4, "Distributor Deposit", cashEntry.AcNo, "Updated Successfully!");
                    //    }
                    //    catch (Exception ex)
                    //    {

                    //        throw;
                    //    }

                    //    return true;
                    //}
                    //else if (evnt == "register")
                    if (evnt == "register")
                    {
                        tblCommissionConversion.Status      = "P";
                        tblCommissionConversion.CheckedDate = System.DateTime.Now;

                        //insert into gl_trans_dtl and gl_trans_mst and RegInfo
                        var successOrErrorMsg = _CommissionConversionService.DataInsertToTransMSTandDTL(tblCommissionConversion);

                        //Insert into audit trial audit and detail
                        TblCommissionConversion prevModel = _CommissionConversionService.GetCommissionConversionByTransNo(tblCommissionConversion.TransNo);
                        prevModel.Status      = "default";//insert for only audit trail
                        prevModel.CheckedUser = "";
                        _auditTrailService.InsertUpdatedModelToAuditTrail(tblCommissionConversion, prevModel, tblCommissionConversion.CheckedUser, 9, 4, "Commission Conversion", tblCommissionConversion.Mphone, "Approved Successfully!");


                        return(successOrErrorMsg);
                    }
                    else
                    {
                        tblCommissionConversion.Status      = "R";// R means Reject
                        tblCommissionConversion.CheckedDate = System.DateTime.Now;
                        _CommissionConversionService.UpdateByStringField(tblCommissionConversion, "TransNo");

                        //Insert into audit trial audit and detail
                        TblCommissionConversion prevModel = _CommissionConversionService.GetCommissionConversionByTransNo(tblCommissionConversion.TransNo);
                        prevModel.Status      = "default";//insert for only audit trail
                        prevModel.CheckedUser = "";
                        _auditTrailService.InsertUpdatedModelToAuditTrail(tblCommissionConversion, prevModel, tblCommissionConversion.CheckedUser, 9, 4, "Commission Conversion", tblCommissionConversion.Mphone, "Rejected Successfully!");

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                return(errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString()));
            }
        }
Ejemplo n.º 9
0
        public object SaveMapOrRemapCbsAccount(BatchUpdateModel model)
        {
            StringBuilderService builder = new StringBuilderService();
            var cbsInfosList             = ConvertBatchUpdateModelToMtCbsinfoModel(model);

            string inactiveCbsAccountNo = string.Empty;
            int    allowAccNo           = 3;
            int    count        = 0;
            int    countPending = 0;
            int    totalCount   = 0;
            bool   allowMap     = false;

            count = _repository.CheckEligibilityMappingByMphone(cbsInfosList[0].Mphone);
            foreach (var value in cbsInfosList)
            {
                if (value.MakeStatus == "A")
                {
                    countPending++;
                }
            }
            totalCount = count + countPending;
            if (count <= 2 && totalCount <= 3)
            {
                allowMap = true;
            }
            if (totalCount > 3)
            {
                return("Please do not try to activate more than three account");
            }
            if (countPending > 3)
            {
                return("Please do not try to activate more than three account");
            }
            if (count > 3)
            {
                return("Three accont activated already");
            }
            foreach (var item in cbsInfosList)
            {
                bool isRegInfoExist = _repository.IsRegInfoExist(item.Mphone);

                if (!isRegInfoExist)
                {
                    return("Ok Account: " + item.Mphone + " is Not exist");                    //reginfo not exist
                }
                if (String.IsNullOrEmpty(item.MakeBy))
                {
                    return(HttpStatusCode.Unauthorized);
                }
                if (item.Status == null && item.MakeStatus == "A")
                {
                    var IsAccNoIsMappedByMblNo = _repository.CheckAccNoIsMappedByMblNo(item.Mobnum, item.Accno);
                    if (Convert.ToInt32(IsAccNoIsMappedByMblNo) == 0)
                    {
                        _repository.Add(item);
                        auditTrailService.InsertModelToAuditTrail(item, item.MakeBy, 8, 3, "Customer Acc Mapping", item.Mphone, "Mapped Suucessful");
                    }
                    else
                    {
                        return(HttpStatusCode.BadRequest);
                    }
                }
                if ((item.Status != item.MakeStatus) && item.Status != null)
                {
                    if (item.MakeStatus == "A")
                    {
                        if (allowMap)
                        {
                            var cbsInfoPrev = _repository.GetMappedAccountByAccNo(item.Accno);
                            _repository.ActiveCbsAccountByAccountNo(item.Accno, item.MakeBy, item.Ubranch);
                            var cbsInfoCurrent = _repository.GetMappedAccountByAccNo(item.Accno);
                            auditTrailService.InsertUpdatedModelToAuditTrail(cbsInfoCurrent, cbsInfoPrev, item.MakeBy, 8, 4, "Customer Acc Mapping", item.Mphone, "Successfully Map or Remapped");
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        var cbsInfoPrev = _repository.GetMappedAccountByAccNo(item.Accno);
                        _repository.InactiveCbsAccountByAccountNo(item.Accno, item.MakeBy, item.Ubranch);
                        var cbsInfoCurrent = _repository.GetMappedAccountByAccNo(item.Accno);
                        auditTrailService.InsertUpdatedModelToAuditTrail(cbsInfoCurrent, cbsInfoPrev, item.MakeBy, 8, 4, "Customer Acc Mapping", item.Mphone, "Successfully Map or Remapped");
                    }
                }
            }
            return(HttpStatusCode.OK);
        }