public string ConvertToBusinessAccount(string jsonCustomer) { string error = ""; Customer customer = SerializationHelper.DeserializeFromJsonString <Customer>(jsonCustomer); if (customer.Business == null) { error = "Aucun paramtres de Compte Business Entrée"; KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>(error); var result = SerializationHelper.SerializeToJson(koloWs); return(result); } else if (customer.Person == null) { error = "Aucun paramtres de la personne Entrée"; KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>(error); var result = SerializationHelper.SerializeToJson(koloWs); return(result); } else { var context = new KoloAndroidEntities(); Business business = context.Businesses.Add(customer.Business); BusinessContact businessContact = context.BusinessContacts.Add(new BusinessContact() { IdBusiness = customer.IdCustomer, IdContact = customer.IdCustomer }); context.SaveChanges(); KoloWsObject <Business> koloWs = new KoloWsObject <Business>(error, business); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } }
public string DoTransfertA2C(string jsonTransfert2c) { var Context = new KoloAndroidEntities(); Context.Dispose(); return(null); }
public string GetAccountDatas(int idCustomer) { var Context = new KoloAndroidEntities(); Context.Configuration.ProxyCreationEnabled = false; Customer customer = Context.Customers.FirstOrDefault(c => c.IdCustomer == idCustomer); List <ExternalAccount> externalAccounts = Context.ExternalAccounts.Where(c => c.IdCustomer == idCustomer).ToList(); List <CreditCardInfo> cards = new List <CreditCardInfo>(); foreach (ExternalAccount e in externalAccounts) { if (e.IdCreditCard > 0) { cards.Add(Context.CreditCardInfoes.FirstOrDefault(c => c.IdCreditCardInfo == e.IdCreditCard)); } } Person person = Context.People.FirstOrDefault(p => p.IdCustomer == idCustomer); var tuple = new Tuple <Customer, List <ExternalAccount>, List <CreditCardInfo>, Person>(customer, externalAccounts, cards, person); KoloWsObject <Tuple <Customer, List <ExternalAccount>, List <CreditCardInfo>, Person> > koloWs = new KoloWsObject <Tuple <Customer, List <ExternalAccount>, List <CreditCardInfo>, Person> >("", tuple); Context.Dispose(); var result = SerializationHelper.SerializeToJson(koloWs); return(result); }
public string GetCustomerByIdCustomerAndNumber(int idCustomer, string number) { var Context = new KoloAndroidEntities(); SimpleContact simpleContact = new SimpleContact() { FirstName = "name...", LastName = "Full", Telephone = "Phone number..." }; Customer outCustomer; var customerQuery = Context.Customers.Include("MobileDevice").Include("Person").Include("Registration"); if (idCustomer > 0) { outCustomer = customerQuery.Where(e => e.IdCustomer == idCustomer).FirstOrDefault(); } else { outCustomer = customerQuery.Where(e => e.Registration.PhoneNumber == number).FirstOrDefault(); } if (outCustomer != null) { simpleContact = new SimpleContact(outCustomer); } KoloWsObject <SimpleContact> koloWs = new KoloWsObject <SimpleContact>("", simpleContact); var result = SerializationHelper.SerializeToJson(koloWs); Context.Dispose(); return(result); }
public string DoAcceptTransfertA2A(string jsonP2pTransfertDetails) { string error = ""; var Context = new KoloAndroidEntities(); var p2pTransfertDetails = SerializationHelper.DeserializeFromJsonString <P2pTransferDetails>(jsonP2pTransfertDetails); var p2P = Context.TransfertP2p.FirstOrDefault(t => t.IdReceiverCustomer == p2pTransfertDetails.ReceiverIdCustomer && t.IdSendingCustomer == p2pTransfertDetails.ReceiverIdCustomer && t.Reference == p2pTransfertDetails.Reference); if (p2P.NeedsConfirmation) { p2P = TransfertP2PHelper.AskConfirmationOfTransfertA2A(p2P, Context, out error); } if (!p2P.NeedsConfirmation) { p2P = TransfertP2PHelper.ConfirmTransfertA2A(p2P, Context, out error); } if (string.IsNullOrEmpty(p2P.Secret)) { p2P.Secret = "HIDDEN BY CYBERIX"; } p2pTransfertDetails = new P2pTransferDetails(p2P); KoloWsObject <P2pTransferDetails> koloWs = new KoloWsObject <P2pTransferDetails>(error, p2pTransfertDetails); var result = SerializationHelper.SerializeToJson(koloWs); Context.Dispose(); return(result); }
public string UpdateBusinessAccount(string jsonBusinessAccount) { string error = ""; Business business = SerializationHelper.DeserializeFromJsonString <Business>(jsonBusinessAccount); if (business == null) { error = "Aucun paramtres de Compte Business Entrée"; KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>(error); var result = SerializationHelper.SerializeToJson(koloWs); return(result); } else { var context = new KoloAndroidEntities(); Business businessAccount = context.Businesses.FirstOrDefault(b => b.IdCustomer == business.IdCustomer); businessAccount.BusinessName = businessAccount.BusinessName ?? businessAccount.BusinessName; businessAccount.IndustryCategoryCode = business.IndustryCategoryCode ?? businessAccount.IndustryCategoryCode; businessAccount.RefIndustryCategory = business.RefIndustryCategory ?? businessAccount.RefIndustryCategory; context.SaveChanges(); KoloWsObject <Business> koloWs = new KoloWsObject <Business>(error, businessAccount); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } }
public string GetCustomerContacts(string contacts, string idCustomer) { var Context = new KoloAndroidEntities(); var result = SerializationHelper.SerializeToJson(""); Context.Dispose(); return(result); }
public string GetTransfert2CashDetailsByIdTransfert2CashDetails(int idTransfert2CashDetails) { var Context = new KoloAndroidEntities(); var outTransfert2CashDetails = Context.Transfert2CashDetails.FirstOrDefault(t => t.IdTransfert2CashDetails == idTransfert2CashDetails); var result = SerializationHelper.SerializeToJson(outTransfert2CashDetails); Context.Dispose(); return(result); }
public string GetTransfert2CashList(int idTransfert2CashDetails) { var Context = new KoloAndroidEntities(); var outTransfert2CashList = Context.Transfert2Cash.Where(e => e.IdReceiverTransfert2CashDetails == idTransfert2CashDetails || e.IdSendingTransfert2CashDetails == idTransfert2CashDetails).ToList(); var result = SerializationHelper.SerializeToJson(outTransfert2CashList); Context.Dispose(); return(result); }
public string GetCustomerAccount(int idCustomer) { var Context = new KoloAndroidEntities(); Customer outCustomer = Context.Customers .Include("MobileDevice").Include("Person").Include("Registration") .FirstOrDefault(e => e.IdCustomer == idCustomer); KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>("", outCustomer); var result = SerializationHelper.SerializeToJson(koloWs); Context.Dispose(); return(result); }
public string UpdateProfileImage(string jsonIdCustomer) { string error = ""; List <KoloNotification> cBHs = null; var context = new KoloAndroidEntities(); cBHs = context.KoloNotifications.Where(c => c.IdCustomer == 1).ToList(); KoloWsObject <List <KoloNotification> > koloWs = new KoloWsObject <List <KoloNotification> >(error, cBHs); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string GetParameters() { var Context = new KoloAndroidEntities(); ParameterInfo parameters = new ParameterInfo(); String error; parameters.Refresh(Context, out error); KoloWsObject <ParameterInfo> koloWs = new KoloWsObject <ParameterInfo>(error, parameters); var result = SerializationHelper.SerializeToJson(koloWs); Context.Dispose(); return(result); }
public string CancelBill(int jsonIdBill) { KoloAndroidEntities context = new KoloAndroidEntities(); Bill bill = context.Bills.FirstOrDefault(b => b.IdBill == jsonIdBill); bill.CodeRefBillStatus = KoloConstants.Operation.BillStatus.CANCELED.ToString(); context.SaveChanges(); KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(true, "", null); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string GetCustomerBalanceHistory(int jsonIdCustomer) { string error = ""; List <CustomerBalanceHistory> cBHs = null; var context = new KoloAndroidEntities(); cBHs = context.CustomerBalanceHistories.Where(c => c.IdCustomerAccount == jsonIdCustomer).ToList(); KoloWsObject <List <CustomerBalanceHistory> > koloWs = new KoloWsObject <List <CustomerBalanceHistory> >(error, cBHs); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string GetTransfertP2pList(int idCustomer) { var Context = new KoloAndroidEntities(); var outTransfertP2pList = Context.TransfertP2p .Include("Receiver.Person").Include("Receiver.MobileDevice") .Include("Sender.Person").Include("Receiver.MobileDevice") .Where(e => e.IdReceiverCustomer == idCustomer || e.IdSendingCustomer == idCustomer).ToList(); var transfersDetails = outTransfertP2pList.Select(t => new P2pTransferDetails(t)).ToList(); var result = SerializationHelper.SerializeToJson(transfersDetails); Context.Dispose(); return(result); }
public string RejectBill(string jsonIdBill) { KoloAndroidEntities context = new KoloAndroidEntities(); int idBill = 0; if (!Int32.TryParse(jsonIdBill, out idBill)) { KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(false, "Bill Not Found", null); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } else { Bill bill = context.Bills.FirstOrDefault(b => b.IdBill == idBill); bill.CodeRefBillStatus = KoloConstants.Operation.BillStatus.CANCELED.ToString(); context.SaveChanges(); KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(true, "", bill); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } }
public string AddMobileDevice(string jsonMobileDevice) { string error = ""; MobileDevice mobileDevice = SerializationHelper.DeserializeFromJsonString <MobileDevice>(jsonMobileDevice); var context = new KoloAndroidEntities(); context.MobileDevices.Add(mobileDevice); context.SaveChanges(); KoloWsObject <MobileDevice> koloWs = new KoloWsObject <MobileDevice> (error, mobileDevice); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string GetCustomerNotifications(int jsonIdCustomer) { string error = ""; List <KoloNotification> cBHs = null; var context = new KoloAndroidEntities(); context.Configuration.ProxyCreationEnabled = false; cBHs = context.KoloNotifications.Where(c => c.IdCustomer == jsonIdCustomer).ToList(); KoloWsObject <List <KoloNotification> > koloWs = new KoloWsObject <List <KoloNotification> >(error, cBHs); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string RevokeMobileDevice(string jsonIdMobileDevice) { string error = ""; MobileDevice mobileDevice = SerializationHelper.DeserializeFromJsonString <MobileDevice>(jsonIdMobileDevice); var context = new KoloAndroidEntities(); context.Configuration.ProxyCreationEnabled = false; var tmp = context.MobileDevices.FirstOrDefault(c => c.IdMobileDevice == mobileDevice.IdMobileDevice); tmp.isActive = false; context.SaveChanges(); KoloWsObject <MobileDevice> koloWs = new KoloWsObject <MobileDevice>(error, tmp); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string DoTransfertA2A(string jsonTransfertP2p) { string error = ""; var tP2P = SerializationHelper.DeserializeFromJsonString <TransfertP2p>(jsonTransfertP2p); var Context = new KoloAndroidEntities(); tP2P = TransfertP2PHelper.SendTransfertA2A(tP2P, Context, out error); if (string.IsNullOrEmpty(tP2P.Secret)) { tP2P.Secret = "HIDDEN BY CYBERIX"; } KoloWsObject <TransfertP2p> koloWs = new KoloWsObject <TransfertP2p>(error, tP2P); var result = SerializationHelper.SerializeToJson(koloWs); Context.Dispose(); return(result); }
public string SendBill(string jsonBillDetails) { BillDetails billDetails = SerializationHelper.DeserializeFromJsonString <BillDetails>(jsonBillDetails); KoloAndroidEntities context = new KoloAndroidEntities(); Tuple <Bill, BillDetail> tuple = billDetails.GetBillAndDetails(); Bill bill = tuple.Item1; BillDetail billDetail = tuple.Item2; bill.BillDetails.Add(billDetail); context.Bills.Add(bill); context.SaveChanges(); KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>("", bill); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string UpdateCustomerAccount(string jsonCustomer) { string error = ""; Customer customer = SerializationHelper.DeserializeFromJsonString <Customer>(jsonCustomer); var context = new KoloAndroidEntities(); var tmp = context.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == customer.IdCustomer); MobileDevice mobileDevice = null; if (customer.MobileDevices[0] != null) { mobileDevice = context.MobileDevices.FirstOrDefault(m => m.IdCustomer == customer.IdCustomer && m.IdMobileDevice == customer.MobileDevices[0].IdMobileDevice); } CustomerHelper.UpdateCustomerAccount(ref tmp, customer, ref mobileDevice, context, out error); context.SaveChanges(); KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>(error, tmp); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); }
public string UpdateBusinessContact(string jsonBusinessContact) { string error = ""; BusinessContact businessContact = SerializationHelper.DeserializeFromJsonString <BusinessContact>(jsonBusinessContact); if (businessContact == null) { error = "Aucun paramtres de Compte Business Contact"; KoloWsObject <BusinessContact> koloWs = new KoloWsObject <BusinessContact>(error); var result = SerializationHelper.SerializeToJson(koloWs); return(result); } else { var context = new KoloAndroidEntities(); BusinessContact businessContactEF = context.BusinessContacts.FirstOrDefault(b => b.IdBusiness == businessContact.IdBusiness); //////////////////////////////////////////////////////// BusinessContactUpdateHistory businessContactUpdateHistory = new BusinessContactUpdateHistory(); businessContactUpdateHistory.Date = DateTime.Now; businessContactUpdateHistory.IdBusiness = businessContact.IdBusiness; businessContactUpdateHistory.IdContact = businessContact.IdContact; businessContactUpdateHistory.OldJobTitle = businessContactEF.JobTitle; businessContactUpdateHistory.NewJobTitle = businessContact.JobTitle; context.BusinessContactUpdateHistories.Add(businessContactUpdateHistory); //////////////////////////////////////////////////////// businessContactEF.IdContact = businessContact.IdContact != 0 ? businessContact.IdContact : businessContactEF.IdContact; businessContactEF.JobTitle = businessContact.JobTitle ?? businessContactEF.JobTitle; context.SaveChanges(); KoloWsObject <BusinessContact> koloWs = new KoloWsObject <BusinessContact>(error, businessContactEF); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } }
public string PayBill(string jsonBillPayement) { BillPayment billPayment = SerializationHelper.DeserializeFromJsonString <BillPayment>(jsonBillPayement); KoloAndroidEntities context = new KoloAndroidEntities(); Bill bill = context.Bills.FirstOrDefault(b => b.IdBill == billPayment.IdBill); if (bill == null) { KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(false, "Bill Not Found", null); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } if (!bill.AllowPartialPayment && bill.TotalBillAmount > billPayment.PaidAmount) { KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(false, "This bill don't allow partial paiment please send all money", null); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } else if (!bill.AllowPartialPayment && bill.TotalBillAmount == billPayment.PaidAmount) { billPayment.DatePaid = DateTime.Now; billPayment.LastPayment = true; bill.CodeRefBillStatus = KoloConstants.Operation.BillStatus.PAID.ToString(); bill.LeftToPay -= billPayment.PaidAmount; KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(true, "", bill); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } if (bill.AllowPartialPayment) { if (bill.LeftToPay == billPayment.PaidAmount) { billPayment.DatePaid = DateTime.Now; billPayment.LastPayment = true; bill.CodeRefBillStatus = KoloConstants.Operation.BillStatus.PAID.ToString(); bill.LeftToPay -= billPayment.PaidAmount; KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(true, "", bill); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } if (bill.LeftToPay > billPayment.PaidAmount) { billPayment.DatePaid = DateTime.Now; billPayment.LastPayment = false; bill.CodeRefBillStatus = KoloConstants.Operation.BillStatus.PAY_PROCESSING.ToString(); bill.LeftToPay -= billPayment.PaidAmount; KoloWsObject <Bill> koloWs = new KoloWsObject <Bill>(true, "", bill); var result = SerializationHelper.SerializeToJson(koloWs); context.Dispose(); return(result); } } return(""); }