Пример #1
0
        public static bool InsertUserGeneralPhoneBook(Guid userGuid, string generalPhoneBookGuid, string newGeneralPhoneBook, decimal sumPrice, bool decreaseFromPanelCharge)
        {
            Business.User userController = new Business.User();
            userController.BeginTransaction();

            try
            {
                if (!userController.DeleteAllUserGeneralPhoneBook(userGuid))
                {
                    throw new Exception("ErrorRecord");
                }
                if (!userController.InsertUserGeneralPhoneBook(userGuid, generalPhoneBookGuid))
                {
                    throw new Exception("ErrorRecord");
                }

                if (decreaseFromPanelCharge && sumPrice != 0)
                {
                    int countNewGeneralPhoneBook = Helper.ImportIntData(newGeneralPhoneBook, "Count");
                    for (int counterNewGeneralPhoneBook = 0; counterNewGeneralPhoneBook < countNewGeneralPhoneBook; counterNewGeneralPhoneBook++)
                    {
                        Facade.Transaction.Decrease(userGuid, Helper.ImportDecimalData(newGeneralPhoneBook, "Price" + counterNewGeneralPhoneBook), TypeCreditChanges.ActivationGeneralPhoneBook, Language.GetString("DecreaseFromPanelChargeForActivationGeneralPhoneBook") + " \"" + Helper.ImportData(newGeneralPhoneBook, "Name" + counterNewGeneralPhoneBook) + "\"", Guid.Empty, userController.DataAccessProvider);
                    }
                }

                userController.CommitTransaction();
            }
            catch (Exception ex)
            {
                userController.RollbackTransaction();
                throw ex;
            }
            return(true);
        }
Пример #2
0
        public static bool InsertUserService(Guid userGuid, string servicesGuids, string newServices, decimal sumPrice, bool decreaseFromPanelCharge)
        {
            Business.User userController = new Business.User();
            userController.BeginTransaction();

            try
            {
                if (!userController.DeleteAllUserService(userGuid))
                {
                    throw new Exception("ErrorRecord");
                }
                if (!userController.InsertUserService(userGuid, servicesGuids))
                {
                    throw new Exception("ErrorRecord");
                }
                if (!userController.InserUserAccessByService(userGuid, servicesGuids))
                {
                    throw new Exception("ErrorRecord");
                }

                if (decreaseFromPanelCharge && sumPrice != 0)
                {
                    int count = Helper.ImportIntData(newServices, "Count");
                    for (int i = 0; i < count; i++)
                    {
                        Facade.Transaction.Decrease(userGuid, Helper.ImportDecimalData(newServices, "Price" + i), TypeCreditChanges.ActivationService, Language.GetString("DecreaseFromPanelChargeForActivationService") + " \"" + Helper.ImportData(newServices, "Title" + i) + "\"", Guid.Empty, userController.DataAccessProvider);
                    }
                }

                userController.CommitTransaction();
            }
            catch (Exception ex)
            {
                userController.RollbackTransaction();
                throw ex;
            }

            return(true);
        }
Пример #3
0
        public static bool UpdateGroupPrice(Guid userGuid, Guid groupPriceGuid, Guid domainGroupPriceGuid)
        {
            Business.User userController = new Business.User();
            userController.BeginTransaction();
            try
            {
                if (groupPriceGuid == Guid.Empty)
                {
                    throw new Exception("CompleteGroupPriceGuid");
                }

                if (!userController.UpdateGroupGuid(userGuid, groupPriceGuid))
                {
                    throw new Exception("ErrorRecord");
                }

                if (domainGroupPriceGuid != Guid.Empty)
                {
                    if (!userController.UpdateDomainGroupPrice(userGuid, domainGroupPriceGuid))
                    {
                        throw new Exception("ErrorRecord");
                    }
                }

                //if (!Facade.SmsRate.UpdateUserSmsRate(userGuid, userController.DataAccessProvider))
                //	throw new Exception("ErrorRecord");

                userController.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                userController.RollbackTransaction();
                throw ex;
            }
        }