public ActionResult AddSingleMember(string jsonData) { SPResponse result = new SPResponse(); string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); CustomerDetail objCustomer = new CustomerDetail(); foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); objCustomer.MobileNo = Convert.ToString(item["MobileNo"]); objCustomer.CardNumber = Convert.ToString(item["CardNo"]); objCustomer.CustomerName = Convert.ToString(item["FullName"]); objCustomer.Gender = Convert.ToString(item["Gender"]); if (!string.IsNullOrEmpty(Convert.ToString(item["BirthDay"]))) { objCustomer.DOB = Convert.ToDateTime(item["BirthDay"]); } objCustomer.CustomerThrough = Convert.ToString(item["Source"]); objCustomer.EnrollingOutlet = Convert.ToString(item["OutletId"]); objCustomer.MemberGroupId = "1000"; objCustomer.DOJ = DateTime.Now; objCustomer.Status = "00"; objAudit.GroupId = GroupId; objAudit.RequestedFor = "User Added"; objAudit.RequestedEntity = "User Added - " + objCustomer.MobileNo; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedDate"]); } result = ITOPS.AddSingleCustomerData(GroupId, objCustomer, objAudit); if (result.ResponseCode == "00") { var subject = "New Customer Added with Mobile No - " + objCustomer.MobileNo; var body = "New Customer Added with Mobile No - " + objCustomer.MobileNo; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } //if (Convert.ToBoolean(IsSMS)) //{ // //Logic to send SMS to Customer whose Name is changed //} } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(Json(result, JsonRequestBehavior.AllowGet)); }
protected Audit_DTO GetLastAudit(string row_id, string table_name) { _dbcontext = new InnonAnalyticsEngineEntities(); tblAudit _audit = _dbcontext.tblAudits.Where(audit => audit.Table_Row_Id == row_id && audit.Table_Name == table_name).OrderByDescending(order => order.Last_Update).FirstOrDefault(); return(Convert_Aduit.Convert(_audit)); }
public ActionResult LoadBonusData(string jsonData) { SPResponse result = new SPResponse(); string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); bool IsSMS = false; string MobileNo = ""; int BonusPoints = 0; string BonusRemark = ""; string OutletId = ""; DateTime ExpiryDate = DateTime.Now; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); MobileNo = Convert.ToString(item["MobileNo"]); OutletId = Convert.ToString(item["OutletId"]); BonusPoints = Convert.ToInt32(item["BonusPoints"]); BonusRemark = Convert.ToString(item["BonusRemark"]); ExpiryDate = Convert.ToDateTime(item["ExpiryDate"]); objAudit.GroupId = GroupId; objAudit.RequestedFor = "Load Bonus"; objAudit.RequestedEntity = "Load Bonus for - " + MobileNo; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedDate"]); IsSMS = Convert.ToBoolean(item["IsSMS"]); } result = ITOPS.AddLoadBonusData(GroupId, MobileNo, OutletId, BonusPoints, BonusRemark, ExpiryDate, Convert.ToString(IsSMS), objAudit); if (result.ResponseCode == "00") { var subject = "Points Loaded for mobile no - " + MobileNo; var body = "Points Loaded for mobile no - " + MobileNo; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (Convert.ToBoolean(IsSMS)) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public override int SaveChanges() { int retVal; try { auditList.Clear(); list.Clear(); auditFactory = new AuditTrailFactory(this); var entityList = ChangeTracker.Entries().Where(p => p.State == System.Data.Entity.EntityState.Added || p.State == System.Data.Entity.EntityState.Deleted || p.State == System.Data.Entity.EntityState.Modified); foreach (var entity in entityList) { tblAudit audit = auditFactory.GetAudit(entity); if (audit != null) { audit.UserId = this.UserId; auditList.Add(audit); list.Add(entity); } } retVal = base.SaveChanges(); if (auditList.Count > 0) { foreach (var audit in auditList) {//add all audits this.tblAudits.Add(audit); } base.SaveChanges(); } } catch (DbEntityValidationException e) { //this.logger.Error("SaveChanges", e); string strEr = ""; foreach (var eve in e.EntityValidationErrors) { strEr = "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:"; strEr = string.Format(strEr, eve.Entry.Entity.GetType().Name, eve.Entry.State); // this.logger.Error(strEr); foreach (var ve in eve.ValidationErrors) { strEr = "- Property: \"{0}\", Error: \"{1}\""; strEr = string.Format(strEr, ve.PropertyName, ve.ErrorMessage); //this.logger.Error(strEr); } } throw e; } catch (Exception ex) { // this.logger.Error("SaveChanges", ex); throw ex; } return(retVal); }
public bool ChangeSMSDetails(string jsonData) { bool result = false; string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); bool IsSMS = false; string CustomerId = ""; bool DisableSMS = false; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); CustomerId = Convert.ToString(item["CustomerId"]); string Disable = Convert.ToString(item["Disable"]); if (Disable == "1") { DisableSMS = true; } objAudit.GroupId = GroupId; objAudit.RequestedFor = "Change SMS setting"; objAudit.RequestedEntity = "Change SMS setting for - " + CustomerId; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedDate"]); IsSMS = Convert.ToBoolean(item["IsSMS"]); } result = ITOPS.ChangeSMSDetails(GroupId, CustomerId, DisableSMS, objAudit); if (result) { var subject = "New Customer Added with Mobile No - " + CustomerId; var body = "New Customer Added with Mobile No - " + CustomerId; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (Convert.ToBoolean(IsSMS)) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { tblAudit objaudit = new tblAudit(); // Getting Action Name string actionName = filterContext.ActionDescriptor.ActionName; //Getting Controller Name string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; var request = filterContext.HttpContext.Request; if (HttpContext.Current.Session["UserID"] != null) { objaudit.UserID = Convert.ToString(HttpContext.Current.Session["UserID"]); } else if (HttpContext.Current.Session["AdminUser"] != null) { objaudit.UserID = Convert.ToString(HttpContext.Current.Session["AdminUser"]); } else { string strUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString().Replace(Environment.UserDomainName + "\\", "").Trim().ToString(); objaudit.UserID = strUser; } objaudit.SessionID = HttpContext.Current.Session.SessionID; // Application SessionID // User IPAddress objaudit.IPAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress; objaudit.PageAccessed = Convert.ToString(filterContext.HttpContext.Request.Url); // URL User Requested objaudit.LoggedInAt = DateTime.Now; // Time User Logged In || And time User Request Method if (actionName == "LogOff") { objaudit.LoggedOutAt = DateTime.Now; // Time User Logged OUT } objaudit.LoginStatus = "A"; objaudit.ControllerName = controllerName; // ControllerName objaudit.ActionName = actionName; Uri myReferrer = request.UrlReferrer; if (myReferrer != null) { string actual = myReferrer.ToString(); if (actual != null) { objaudit.UrlReferrer = request.UrlReferrer.AbsolutePath; } } _IAudit.SaveAudit(objaudit); }
protected Audit_DTO GetLastAudit(string row_id, string table_name, LivePoint_DTO livepoint_dto) { _dbcontext = new InnonAnalyticsEngineEntities(); tblAudit _audit = _dbcontext.tblAudits.Where(audit => audit.Table_Row_Id == row_id && audit.Table_Name == table_name).OrderByDescending(order => order.Last_Update).FirstOrDefault(); if (_audit != null) { livepoint_dto.Last_Changes = $"Previous value {_audit.Old_Values}, Change by {_audit.User_Id}"; livepoint_dto.Last_Updated = _audit.Last_Update; } return(Convert_Aduit.Convert(_audit)); }
public ActionResult ChangeMemberMobile(string jsonData) { SPResponse result = new SPResponse(); string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); bool IsSMS = false; string CustomerId = ""; string MobileNo = ""; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); CustomerId = Convert.ToString(item["CustomerId"]); MobileNo = Convert.ToString(item["MobileNo"]); objAudit.GroupId = GroupId; objAudit.RequestedFor = "Mobile Number Change"; objAudit.RequestedEntity = "CustomerId - " + CustomerId; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedOn"]); IsSMS = Convert.ToBoolean(item["IsSMS"]); } result = ITOPS.UpdateMobileOfMember(GroupId, CustomerId, MobileNo, objAudit); if (result.ResponseCode == "00") { var subject = "Customer Mobile Number changed for CustomerId - " + CustomerId; var body = "Customer Mobile Number changed for CustomerId - " + CustomerId; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (IsSMS) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public bool ChangeMemberName(string jsonData) { bool result = false; string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); bool IsSMS = false; string CustomerId = ""; string Name = ""; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); CustomerId = Convert.ToString(item["CustomerId"]); Name = Convert.ToString(item["Name"]); objAudit.GroupId = GroupId; objAudit.RequestedFor = "Name Change"; objAudit.RequestedEntity = "CustomerId - " + CustomerId; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedOn"]); IsSMS = Convert.ToBoolean(item["IsSMS"]); } result = ITOPS.UpdateNameOfMember(GroupId, CustomerId, Name, objAudit); if (result) { var subject = "Customer name changed for CustomerId - " + CustomerId; var body = "Customer name changed for CustomerId - " + CustomerId; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (IsSMS) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public tblAudit GetAudit(DbEntityEntry entry) { tblAudit audit = new tblAudit(); try { if (!IsAuditable(entry.Entity)) { return(null); } audit.AuditId = Guid.NewGuid(); audit.TableName = GetTableName(entry); audit.RevisionStamp = DateTime.Now; audit.TableIdValue = GetKeyValue(entry); //entry is Added if (entry.State == System.Data.Entity.EntityState.Added) { audit.NewData = GetEntryValueInString(entry, false); audit.Actions = Constants.AuditActions.Insert.ToString(); } //entry in deleted else if (entry.State == System.Data.Entity.EntityState.Deleted) { audit.OldData = GetEntryValueInString(entry, true); audit.Actions = Constants.AuditActions.Deleted.ToString(); } //entry is modified else if (entry.State == System.Data.Entity.EntityState.Modified) { audit.OldData = GetEntryValueInString(entry, true); audit.NewData = GetEntryValueInString(entry, false); audit.Actions = Constants.AuditActions.Updated.ToString(); } } catch (Exception ex) { // this.logger.Error("GetAudit", ex); throw ex; } return(audit); }
protected void SaveAduit(string user_id, string row_id, string table_name, string old_values, string new_values, string comments) { try { _dbcontext = new InnonAnalyticsEngineEntities(); Audit_DTO audit_dto = new Audit_DTO(); audit_dto.Comments = comments; audit_dto.New_Values = new_values; audit_dto.Old_Values = old_values; audit_dto.Table_Name = table_name; audit_dto.Table_Row_Id = row_id; audit_dto.User_Id = user_id; tblAudit tbl_audit = Convert_Aduit.Convert(audit_dto); _dbcontext.tblAudits.Add(tbl_audit); _dbcontext.SaveChanges(); _dbcontext.Dispose(); } catch (Exception ex) { } }
public bool ModifyTransaction(string jsonData) { bool result = false; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); string GroupId = ""; string TransactionId = ""; decimal points = 0; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); TransactionId = Convert.ToString(item["TransactionId"]); if (!string.IsNullOrEmpty(Convert.ToString(item["Points"]))) { points = Convert.ToDecimal(item["Points"]); } objAudit.GroupId = GroupId; objAudit.RequestedFor = "Add / Earn"; objAudit.RequestedEntity = "Transaction For - " + TransactionId; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedOn"]); } result = ITOPS.ModifyTransaction(GroupId, Convert.ToInt64(TransactionId), points, objAudit); } catch (Exception ex) { newexception.AddException(ex, "ModifyTransaction"); } return(result); }
public ActionResult DeleteTransaction(string GroupId, string InvoiceNo, string MobileNo, string InvoiceAmt, string ip_Date, string RequestedBy, string RequestedForum, string RequestedDate) { SPResponse result = new SPResponse(); try { tblAudit objAudit = new tblAudit(); objAudit.GroupId = GroupId; objAudit.RequestedFor = "Delete Transaction"; objAudit.RequestedEntity = "Delete Transaction for Invoice - " + InvoiceNo; objAudit.RequestedBy = RequestedBy; objAudit.RequestedOnForum = RequestedForum; objAudit.RequestedOn = Convert.ToDateTime(RequestedDate); bool IsSMS = false; var dateCancel = Convert.ToDateTime(ip_Date); result = ITOPS.DeleteTransaction(GroupId, InvoiceNo, MobileNo, InvoiceAmt, dateCancel, objAudit); if (result.ResponseCode == "00") { var subject = "Transaction Deleted for - " + InvoiceNo; var body = "Transaction Deleted for - " + InvoiceNo; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (Convert.ToBoolean(IsSMS)) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public bool ChangeSMSDetails(string GroupId, string CustomerId, bool Disable, tblAudit objAudit) { bool status = false; try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { var objCustomer = contextNew.CustomerDetails.Where(x => x.CustomerId == CustomerId).FirstOrDefault(); objCustomer.IsSMS = Disable; contextNew.CustomerDetails.AddOrUpdate(objCustomer); contextNew.SaveChanges(); status = true; } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(status); }
public UserAuditFilter() { _IAudit = new tblAudit(); }
public bool UpdateNameOfMember(string GroupId, string CustomerId, string Name, tblAudit objAudit) { bool status = false; try { CustomerDetail objCustomerDetail = new CustomerDetail(); string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { objCustomerDetail = contextNew.CustomerDetails.Where(x => x.CustomerId == CustomerId).FirstOrDefault(); objCustomerDetail.CustomerName = Name; contextNew.CustomerDetails.AddOrUpdate(objCustomerDetail); contextNew.SaveChanges(); status = true; } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, ""); } return(status); }
public static Audit_DTO Convert(tblAudit audit_tbl) { return(Mapper.Map <tblAudit, Audit_DTO>(audit_tbl)); }
public ActionResult RedeemPointsData(string jsonData) { SPResponse result = new SPResponse(); string GroupId = ""; try { JavaScriptSerializer json_serializer = new JavaScriptSerializer(); json_serializer.MaxJsonLength = int.MaxValue; object[] objData = (object[])json_serializer.DeserializeObject(jsonData); tblAudit objAudit = new tblAudit(); bool IsSMS = false; string MobileNo = ""; string TransactionDate = ""; string InvoiceNumber = ""; string InvoiceAmount = ""; string OutletId = ""; string PointsToRedeem = ""; string TxnType = ""; foreach (Dictionary <string, object> item in objData) { GroupId = Convert.ToString(item["GroupID"]); MobileNo = Convert.ToString(item["MobileNo"]); OutletId = Convert.ToString(item["OutletId"]); TransactionDate = Convert.ToString(item["TransactionDate"]); InvoiceNumber = Convert.ToString(item["InvoiceNumber"]); InvoiceAmount = Convert.ToString(item["InvoiceAmount"]); PointsToRedeem = Convert.ToString(item["RedeemPoints"]); TxnType = Convert.ToString(item["TxnType"]); objAudit.GroupId = GroupId; objAudit.RequestedFor = "Redeem Point"; objAudit.RequestedEntity = "Mobile No - " + MobileNo; objAudit.RequestedBy = Convert.ToString(item["RequestedBy"]); objAudit.RequestedOnForum = Convert.ToString(item["RequestedForum"]); objAudit.RequestedOn = Convert.ToDateTime(item["RequestedOn"]); IsSMS = Convert.ToBoolean(item["IsSMS"]); } result = ITOPS.AddRedeemPointsData(GroupId, MobileNo, OutletId, Convert.ToDateTime(TransactionDate), DateTime.Now, InvoiceNumber, InvoiceAmount, Convert.ToDecimal(PointsToRedeem), Convert.ToString(IsSMS), TxnType, objAudit); if (result.ResponseCode == "00") { var subject = "Points Redeem for mobile no - " + MobileNo; var body = "Points Redeem for mobile no - " + MobileNo; body += "<br/><br/> Regards <br/> Blue Ocktopus Team"; SendEmail(GroupId, subject, body); } if (IsSMS) { //Logic to send SMS to Customer whose Name is changed } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public SPResponse UpdateMobileOfMember(string GroupId, string CustomerId, string MobileNo, tblAudit objAudit) { SPResponse result = new SPResponse(); try { CustomerDetail objCustomerDetail = new CustomerDetail(); List <TransactionMaster> lstObjTxn = new List <TransactionMaster>(); List <PointsExpiry> lstobjpoints = new List <PointsExpiry>(); TransferPointsDetail objtransferPointsDetail = new TransferPointsDetail(); string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { var objExisting = contextNew.CustomerDetails.Where(x => x.MobileNo == MobileNo).FirstOrDefault(); if (objExisting == null) { objCustomerDetail = contextNew.CustomerDetails.Where(x => x.CustomerId == CustomerId).FirstOrDefault(); string oldno = objCustomerDetail.MobileNo; objCustomerDetail.MobileNo = MobileNo; lstObjTxn = contextNew.TransactionMasters.Where(x => x.CustomerId == CustomerId).Take(10000).ToList(); if (lstObjTxn != null) { foreach (var trans in lstObjTxn) { trans.MobileNo = MobileNo; contextNew.TransactionMasters.AddOrUpdate(trans); contextNew.SaveChanges(); } } lstobjpoints = contextNew.PointsExpiries.Where(x => x.CustomerId == CustomerId).Take(10000).ToList(); if (lstobjpoints != null) { foreach (var points in lstobjpoints) { points.MobileNo = MobileNo; contextNew.PointsExpiries.AddOrUpdate(points); contextNew.SaveChanges(); } } objtransferPointsDetail.NewMobileNo = MobileNo; objtransferPointsDetail.OldMobileNo = oldno; objtransferPointsDetail.GroupId = GroupId; objtransferPointsDetail.Datetime = DateTime.Now; objtransferPointsDetail.Points = objCustomerDetail.Points; contextNew.TransferPointsDetails.AddOrUpdate(objtransferPointsDetail); contextNew.SaveChanges(); contextNew.CustomerDetails.AddOrUpdate(objCustomerDetail); contextNew.SaveChanges(); result.ResponseCode = "00"; result.ResponseMessage = "Mobile Number Updated Successfully"; } else { result.ResponseCode = "01"; result.ResponseMessage = "Mobile Number Already Exist"; } } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public SPResponse AddRedeemPointsData(string GroupId, string MobileNo, string OutletId, DateTime TxnDate, DateTime RequestDate, string InvoiceNo, string InvoiceAmt, decimal Points, string IsSMS, string TxnType, tblAudit objAudit) { SPResponse result = new SPResponse(); try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { result = contextNew.Database.SqlQuery <SPResponse>("sp_BurnRW_New_ITOPS @pi_MobileNo, @pi_OutletId, @pi_TxnDate, @pi_RequestDate, @pi_InvoiceNo, @pi_InvoiceAmt,@pi_RedeemPoints, @pi_LoginId, @pi_RequestBy, @pi_RequestedOnForum, @pi_SMSFlag, @pi_TxnType", new SqlParameter("@pi_MobileNo", MobileNo), new SqlParameter("@pi_OutletId", OutletId), new SqlParameter("@pi_TxnDate", TxnDate.ToString("yyyy-MM-dd")), new SqlParameter("@pi_RequestDate", RequestDate.ToString("yyyy-MM-dd")), new SqlParameter("@pi_InvoiceNo", InvoiceNo), new SqlParameter("@pi_InvoiceAmt", InvoiceAmt), new SqlParameter("@pi_RedeemPoints", Points), new SqlParameter("@pi_LoginId", ""), new SqlParameter("@pi_RequestBy", objAudit.RequestedBy), new SqlParameter("@pi_RequestedOnForum", objAudit.RequestedOnForum), new SqlParameter("@pi_SMSFlag", IsSMS), new SqlParameter("@pi_TxnType", TxnType)).FirstOrDefault <SPResponse>(); } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public bool ModifyTransaction(string GroupId, long TransactionId, decimal points, tblAudit objAudit) { bool status = false; string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { using (DbContextTransaction transaction = contextNew.Database.BeginTransaction()) { try { var objTransaction = contextNew.TransactionMasters.Where(x => x.SlNo == TransactionId).FirstOrDefault(); var customerDetails = contextNew.CustomerDetails.Where(x => x.MobileNo == objTransaction.MobileNo).FirstOrDefault(); var PointExpiry = contextNew.PointsExpiries.Where(x => x.MobileNo == objTransaction.MobileNo && x.Status == "00").ToList(); var NewPointExpiry = contextNew.PointsExpiries.Where(x => x.MobileNo == objTransaction.MobileNo && x.Status == "00").OrderByDescending(y => y.ExpiryDate).FirstOrDefault(); var oldTransactionPoints = objTransaction.PointsEarned; objTransaction.PointsEarned = points; contextNew.TransactionMasters.AddOrUpdate(objTransaction); contextNew.SaveChanges(); foreach (var item in PointExpiry) { item.Status = "01"; contextNew.PointsExpiries.AddOrUpdate(item); contextNew.SaveChanges(); } PointsExpiry objPointExpiry = new PointsExpiry(); objPointExpiry.Points = (customerDetails.Points - oldTransactionPoints) + points; objPointExpiry.CounterId = NewPointExpiry.CounterId; objPointExpiry.MobileNo = NewPointExpiry.MobileNo; objPointExpiry.Datetime = DateTime.Now; objPointExpiry.EarnDate = NewPointExpiry.EarnDate; objPointExpiry.ExpiryDate = NewPointExpiry.ExpiryDate; objPointExpiry.Status = "00"; objPointExpiry.InvoiceNo = NewPointExpiry.InvoiceNo; objPointExpiry.GroupId = NewPointExpiry.GroupId; objPointExpiry.CustomerId = NewPointExpiry.CustomerId; contextNew.PointsExpiries.AddOrUpdate(objPointExpiry); contextNew.SaveChanges(); customerDetails.Points = (customerDetails.Points - oldTransactionPoints) + points; contextNew.CustomerDetails.AddOrUpdate(customerDetails); contextNew.SaveChanges(); using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } transaction.Commit(); status = true; } catch (Exception ex) { transaction.Rollback(); newexception.AddException(ex, GroupId); } } } return(status); }
public SPResponse DeleteTransaction(string GroupId, string InvoiceNo, string MobileNo, string InvoiceAmt, DateTime ip_Date, tblAudit objAudit) { SPResponse result = new SPResponse(); try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { result = contextNew.Database.SqlQuery <SPResponse>("sp_CancelTxn1_ITOPS @pi_MobileNo, @pi_InvoiceNo, @pi_InvoiceAmt, @pi_RequestDate, @pi_Datetime, @pi_LoginId,@pi_RequestBy, @pi_RequestedOnForum, @pi_SMSFlag", new SqlParameter("@pi_MobileNo", MobileNo), new SqlParameter("@pi_InvoiceNo", InvoiceNo), new SqlParameter("@pi_InvoiceAmt", InvoiceAmt), new SqlParameter("@pi_RequestDate", objAudit.RequestedOn), new SqlParameter("@pi_Datetime", ip_Date), new SqlParameter("@pi_LoginId", ""), new SqlParameter("@pi_RequestBy", objAudit.RequestedBy), new SqlParameter("@pi_RequestedOnForum", objAudit.RequestedOnForum), new SqlParameter("@pi_SMSFlag", "0")).FirstOrDefault <SPResponse>(); } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public SPResponse AddLoadBonusData(string GroupId, string MobileNo, string OutletId, int BonusPoints, string BonusRemark, DateTime ExpiryDate, string IsSMS, tblAudit objAudit) { SPResponse result = new SPResponse(); try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { result = contextNew.Database.SqlQuery <SPResponse>("sp_BonusPoints_ITOPS @pi_MobileNo, @pi_OutletId, @pi_RequestDate, @pi_ExpiryDate, @pi_BonusRemarks, @pi_BonusPoints,@pi_LoginId, @pi_RequestBy, @pi_RequestedOnForum, @pi_SMSFlag", new SqlParameter("@pi_MobileNo", MobileNo), new SqlParameter("@pi_OutletId", OutletId), new SqlParameter("@pi_RequestDate", objAudit.RequestedOn.ToString("yyyy-MM-dd")), new SqlParameter("@pi_ExpiryDate", ExpiryDate.ToString("yyyy-MM-dd")), new SqlParameter("@pi_BonusRemarks", BonusRemark), new SqlParameter("@pi_BonusPoints", BonusPoints), new SqlParameter("@pi_LoginId", ""), new SqlParameter("@pi_RequestBy", objAudit.RequestedBy), new SqlParameter("@pi_RequestedOnForum", objAudit.RequestedOnForum), new SqlParameter("@pi_SMSFlag", IsSMS)).FirstOrDefault <SPResponse>(); } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }
public SPResponse AddSingleCustomerData(string GroupId, CustomerDetail objCustomer, tblAudit objAudit) { SPResponse result = new SPResponse(); try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { var ObjMobileNo = contextNew.CustomerDetails.Where(x => x.MobileNo == objCustomer.MobileNo).FirstOrDefault(); if (ObjMobileNo == null) { var CustomerId = contextNew.CustomerDetails.OrderByDescending(x => x.CustomerId).Select(y => y.CustomerId).FirstOrDefault(); var NewId = Convert.ToInt64(CustomerId) + 1; objCustomer.CustomerId = Convert.ToString(NewId); objCustomer.Points = 0; contextNew.CustomerDetails.AddOrUpdate(objCustomer); contextNew.SaveChanges(); result.ResponseCode = "00"; result.ResponseMessage = "Member Added Successfully"; } else { result.ResponseCode = "01"; result.ResponseMessage = "Mobile Number Already Exist"; } } using (var context = new CommonDBContext()) { context.tblAudits.Add(objAudit); context.SaveChanges(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(result); }