Esempio n. 1
0
        public List <MobileOperator> DisplayOperators()
        {
            List <MobileOperator> operatorList = new List <MobileOperator>();

            sqlconnection();
            connection.Open();
            SqlCommand    sqlCommand    = new SqlCommand("select * from fn_DisplayOperator() ", connection);
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                MobileOperator mobileOperator = new MobileOperator();
                mobileOperator.OperatorId   = (int)sqlDataReader["OperatorId"];
                mobileOperator.OperatorName = (string)sqlDataReader["OperatorName"];
                operatorList.Add(mobileOperator);
            }
            connection.Close();
            return(operatorList);
        }
Esempio n. 2
0
        public void AddNewMobileOperatorToDatabase(MobileOperator newMobileOperator)
        {
            try
            {
                SqlConnection sqlConn = new SqlConnection(@"Data Source=VARUN;Initial Catalog=CellPhoneDatabase;Integrated Security=True");
                sqlConn.Open();

                string query = @"insert into mobile_operator(name,rating) values(" + "\'" + newMobileOperator.Name + "\'" + "," + newMobileOperator.rating + ");";

                using (SqlCommand sqlCommand = new SqlCommand(query, sqlConn))
                {
                    sqlCommand.ExecuteNonQuery();
                    Console.WriteLine("Done...");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public bool AddOperator(MobileOperator mobileOperator)
        {
            List <MobileOperator> mobileOperators = dataAccess.mobileOperators();

            foreach (MobileOperator operatorr in mobileOperators)
            {
                if (operatorr.OperatorName.ToLower() == mobileOperator.OperatorName.ToLower())
                {
                    throw new InvalidData("Please enter another operator name");
                }
                if (mobileOperator.OperatorRating > 5 || mobileOperator.OperatorRating < 0)
                {
                    throw new RatingOverLoadedException("Please enter rating between 0 and 5");
                }
            }
            DataAccess dataAccess1 = new DataAccess();

            dataAccess1.AddOperator(mobileOperator);
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Выводит найденого мобильного оператора или возвращает false в случае неудачи.
        /// </summary>
        /// <param name="mobileOperator">Мобильный оператор.</param>
        /// <param name="value">Эквивалентный строковый код.</param>
        /// <returns>True, если поиск был успешен, иначе false.</returns>
        public static bool TryFind(MobileOperator mobileOperator, out string value)
        {
            value = string.Empty;
            string?name = Enum.GetName(mobileOperator);

            if (name is null)
            {
                return(false);
            }

            PropertyInfo?property = typeof(MobileOperators).GetProperty(name, BindingFlags.Public | BindingFlags.Static);

            if (property is null)
            {
                return(false);
            }

            value = property.GetValue(null) as string ?? value;
            return(true);
        }
Esempio n. 5
0
        //Get Top Two Mobile Operators with Best Ratings
        public List <MobileOperator> GetTopTwoMobileOperators()
        {
            DataTable dtblTopMobileOperators = new DataTable();

            List <MobileOperator> mobileOperators = new List <MobileOperator>();

            try
            {
                SqlConnection sqlConn = new SqlConnection(_connectionString);
                sqlConn.Open();

                SqlCommand sqlComm = new SqlCommand();

                sqlComm.CommandType = CommandType.StoredProcedure;
                sqlComm.CommandText = "spGetTwoHighestRatedMobileOperators";

                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlComm.CommandText, sqlConn);
                sqlDataAdapter.Fill(dtblTopMobileOperators);

                foreach (DataRow dataRow in dtblTopMobileOperators.Rows)
                {
                    MobileOperator mobileOperator = new MobileOperator();

                    mobileOperator.Name   = (string)dataRow["name"];
                    mobileOperator.Rating = (int)dataRow["rating"];
                    mobileOperator.Id     = (int)dataRow["id"];

                    mobileOperators.Add(mobileOperator);
                }

                sqlConn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message); //Change
            }

            return(mobileOperators);
        }
Esempio n. 6
0
        // SUMMARY: Try to parse MobileOperator by name (Dimoco)
        public MobileOperator TryParseMobileOperator(string name)
        {
            name = name.Trim();
            switch (name)
            {
                #region # CZ Operators #
            case "CZ_EUROTEL":
            case "CZ_O2": return(MobileOperator.CreateManager().Load(49));

            case "CZ_TMOBILE":
            case "CZ_T-MOBILE": return(MobileOperator.CreateManager().Load(50));

            case "CZ_OSKAR":
            case "CZ_VODAFONE": return(MobileOperator.CreateManager().Load(53));

                #endregion
                #region # AT Operators #
                //
                #endregion
            default: return(null);
            }
        }
 public static void AddOperators()
 {
     try
     {
         Console.Write("enter no. of Operators you want to add : ");
         int n = Convert.ToInt32(Console.ReadLine());
         for (int i = 0; i < n; i++)
         {
             MobileOperator mobileOperator = new MobileOperator();
             Console.WriteLine("enter operator name ");
             mobileOperator.OperatorName = Console.ReadLine();
             Console.WriteLine("enter operator Rating ");
             mobileOperator.OperatorRating = Convert.ToDecimal(Console.ReadLine());
             business.AddOperator(mobileOperator);
         }
         Console.WriteLine("--------------------------");
         Console.WriteLine("mobile Operator added successfully");
         Console.WriteLine("--------------------------");
     }
     catch (InvalidData e)
     {
         Console.WriteLine("--------------------------");
         Console.WriteLine(e.Message);
         Console.WriteLine("--------------------------");
     }
     catch (RatingOverLoadedException e)
     {
         Console.WriteLine("--------------------------");
         Console.WriteLine(e.Message);
         Console.WriteLine("--------------------------");
     }
     catch (Exception e)
     {
         Console.WriteLine("--------------------------");
         Console.WriteLine(e.Message);
         Console.WriteLine("--------------------------");
     }
 }
Esempio n. 8
0
        //Wikipedia(
        //Swisscomm 75,79
        //Sunrise 76
        //Salt/Orange 78)


        public override bool TryParseMobileOperator()
        {
            if (!this.Msisnd.StartsWith("41"))
            {
                this.Msisnd = "41" + this.Msisnd;
            }


            //SimTest: Swisscom 0041787472088, Swisscom2 0041797745371
            if (this.Msisnd.StartsWith("4177") ||
                this.Msisnd.StartsWith("4179"))
            {
                this.MobileOperator = MobileOperator.CreateManager().Load(322);
                return(false);
            }


            ///SimTest: CH_Salt 0041765005727  , DB: Orange
            else if (this.Msisnd.StartsWith("4178"))
            {
                this.MobileOperator = MobileOperator.CreateManager().Load(321);
                return(false);
            }


            //SimTest : Ch Sunrise : 41795541571
            else if (this.Msisnd.StartsWith("4176"))
            {
                this.MobileOperator = MobileOperator.CreateManager().Load(318);
                return(false);
            }

            Log.Error("ISendNumber:: MobileOperator is not loaded for some reason (" + this.Msisnd + ")");
            this.Status  = false;
            this.Message = this.ErrorMessage;
            return(true);
        }
Esempio n. 9
0
 public bool AddOperator(MobileOperator mobileOperator)
 {
     return(dataAccess.AddOperator(mobileOperator));
 }
Esempio n. 10
0
        public async Task <IActionResult> Qeydiyyat(RegisterViewModel registerViewModel)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Menimhesabim", "Hesab"));
            }

            MobileOperator mobileOperatorFromDb = _context.MobileOperators.FirstOrDefault(mo => mo.Id == registerViewModel.MobileOperatorId);

            if (!ModelState.IsValid)
            {
                ViewBag.MobileOperators = _context.MobileOperators;
                return(View(registerViewModel));
            }

            if (registerViewModel.UploadFile == null)
            {
                ViewBag.MobileOperators = _context.MobileOperators;
                ModelState.AddModelError("", "Zəhmət olmasa, şəkil yükləyin");
                return(View(registerViewModel));
            }

            CustomUser customUser = new CustomUser
            {
                FirstName        = registerViewModel.FirstName.Trim(),
                UserName         = registerViewModel.Email.Trim(),
                Email            = registerViewModel.Email.Trim(),
                MobileOperatorId = registerViewModel.MobileOperatorId,
                PhoneNumber      = mobileOperatorFromDb.MobileOperatorCode + registerViewModel.PhoneNumber.Trim()
            };

            if (registerViewModel.LastName != null)
            {
                customUser.LastName = registerViewModel.LastName.Trim();
            }

            IdentityResult result = await _userManager.CreateAsync(customUser, registerViewModel.Password);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Bu email artıq qeydiyyatdan keçirilib və ya şifrə tələblərə uyğun deyil.");
                ViewBag.MobileOperators = _context.MobileOperators;
                return(View(registerViewModel));
            }

            if (registerViewModel.UploadFile.ContentType.Contains("image/jpg") || registerViewModel.UploadFile.ContentType.Contains("image/jpeg"))
            {
                if (registerViewModel.UploadFile.Length > (2 * 1024 * 1024))
                {
                    await _userManager.DeleteAsync(customUser);

                    await _context.SaveChangesAsync();

                    ViewBag.MobileOperators = _context.MobileOperators;
                    ModelState.AddModelError("", "Şəklin həcmi 2MB'dan çox ola bilməz.");
                    return(View(registerViewModel));
                }

                string folderPath = Path.Combine(_env.WebRootPath, "MainPageFiles", "images", "users");
                fileName = Guid.NewGuid().ToString() + "_istifadechi_" + registerViewModel.UploadFile.FileName;
                string filePath = Path.Combine(folderPath, fileName);

                using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
                {
                    await registerViewModel.UploadFile.CopyToAsync(fileStream);
                }
                customUser.ProfilePictureURL = fileName;
            }
            else
            {
                await _userManager.DeleteAsync(customUser);

                await _context.SaveChangesAsync();

                ViewBag.MobileOperators = _context.MobileOperators;
                ModelState.AddModelError("", "Zəhmət olmasa, tələb olunan formatda şəkil yükləyin");
                return(View(registerViewModel));
            }

            await _userManager.AddToRoleAsync(customUser, "İstifadəçi");

            await _context.SaveChangesAsync();

            string emailConfirmationToken = await _userManager.GenerateEmailConfirmationTokenAsync(customUser);

            #region Sending Email Confirmation Message
            string messageSubject = "Hesabın təsdiqlənməsi";
            string messageBody    = $"<table style='width:100%;background-color:#292C34;padding:50px'><thead style ='width:100%;display:flex;justify-content:center;'><tr style ='width:100%;display:flex;justify-content:center;'><th style ='width:100%;color:#F9F9F9;font-family:Roboto, sans-serif;font-weight:400;font-size:50px'>Kirayemlak.az</th></tr><thead><tbody><tr><td style ='padding:30px 0px;color:#888888;font-family:Roboto Condensed, sans-serif;font-size:20px;text-align:center;'>Hörmətli istifadəçi, qeydiyyatdan uğurla keçdiniz. Hesabınızı təsdiqləmək üçün aşağıdakı 'Hesabını təsdiqlə' düyməsinə tıklayın.</td></tr><tr><td style ='font-family:Roboto Condensed, sans-serif;text-align:center;'><a href='http://kirayemlak.az/Hesab/Tesdiqetme?userId={customUser.Id}&emailConfirmationToken={emailConfirmationToken}' style ='text-decoration:none;padding:10px 30px;border-radius:3px;background-color:#F9F9F9;color:#292C34;font-weight:lighter;font-size:20px;cursor:pointer;'>Hesabını təsdiqlə</a></td></tr></tbody></table>";
            await UtilityRealEstate.SendMessage(_configuration, registerViewModel.Email, messageSubject, messageBody, customUser, customUser, emailConfirmationToken);

            #endregion

            ViewBag.MobileOperators       = _context.MobileOperators;
            TempData["AccountRegistered"] = true;
            return(View());
        }
Esempio n. 11
0
        // TODO: Dummy function.. make this more dynamic
        public ActionResult SendNumber(string number)
        {
            if (string.IsNullOrEmpty(number))
            {
                return(this.Json(new { status = false, message = "There is no input" }, JsonRequestBehavior.AllowGet));
            }

            // DELETE THIS AFTER TESTING
            if (number == "33228")
            {
                Report.TryReportPxid(this.MobiContext.HttpContext.Request);
                return(this.Json(new { status = true, message = "Vaše žádost byla úspěšně odeslána" }, JsonRequestBehavior.AllowGet));
            }

            MobileOperator mobileOperator = null;

            number = number.Replace(" ", string.Empty).Replace("+", string.Empty);

            // check if number is correct
            for (int i = 0; i < number.Length; i++)
            {
                if (!Char.IsNumber(number[i]))
                {
                    Log.Error("Number is not in correct format (" + number + ")");
                    return(this.Json(new { status = false, message = "Incorrect format" }, JsonRequestBehavior.AllowGet));
                }
            }

            if (!number.StartsWith("420"))
            {
                number = "420" + number;
            }

            // TMOBILE
            if (number.StartsWith("42073"))
            {
                mobileOperator = MobileOperator.CreateManager().Load(50);
            }
            // O2
            else if (number.StartsWith("42072") || number.StartsWith("42070"))
            {
                mobileOperator = MobileOperator.CreateManager().Load(49);
            }
            // VODAFONE
            else if (number.StartsWith("42077"))
            {
                mobileOperator = MobileOperator.CreateManager().Load(53);
            }
            // Ufone
            else if (number.StartsWith("42079"))
            {
                mobileOperator = MobileOperator.CreateManager().Load(52);
            }

            if (mobileOperator == null)
            {
                Log.Error("MobileOperator is not loaded for some reason (" + number + ")");
                return(this.Json(new { status = false, message = "Error" }, JsonRequestBehavior.AllowGet));
            }

            ServiceConfiguration serviceConfiguration = ServiceConfiguration.CreateManager().Load(this.MobiContext.Service.ServiceData.ServiceConfiguration.ID);

            Log.Info("SendNumber::Before sent number is " + number);

            // TODO: remove url to config
            Cashflow.Client.MobileExtensionClient client = new Cashflow.Client.MobileExtensionClient("http://v10.api.cashflow-payment.com/mobile.svc/soap12");

            try
            {
                SendSmsRequest smsRequest = new SendSmsRequest(RequestMode.Default,
                                                               string.Empty,
                                                               serviceConfiguration.PaymentConfiguration.PaymentCredentials.Username,                       // username
                                                               serviceConfiguration.PaymentConfiguration.PaymentCredentials.Password,                       // password
                                                               serviceConfiguration.PaymentConfiguration.BehaviorModel.Guid,                                //bm
                                                               MobiContext.Service.ServiceData.Product.ExternalProductGuid,                                 //product
                                                               serviceConfiguration.PaymentConfiguration.PaymentInterface.ExternalPaymentInterfaceGuid,     //interface
                                                               MobiContext.Service.ServiceData.FallbackCountry.TwoLetterIsoCode,
                                                               serviceConfiguration.PaymentConfiguration.PaymentProvider.ExternalPaymentProviderGuid.Value, //provider
                                                               mobileOperator.ExternalMobileOperatorID.ToString(),
                                                               number,
                                                               "DOBRY DEN,VITAME VAS V SMS CHATU,VASE SMS ZPRAVA BYLA DORUCENA A BYLA PREDANA VASEMU KONTAKTU.OD 18 LET.CENA ZA SMS/60 KC VC.DPH,INFOLINKA 844444484",
                                                                                          //"Vítejte na dívky",
                                                               Guid.NewGuid().ToString(), // "send sms ref."
                                                               string.Empty,
                                                               null);
                SendSmsResponse response = client.SendSms(smsRequest);

                // Report.TryReportPxid(this.MobiContext.HttpContext.Request);

                if (response.Status.Code == MessageStatusCode.Success)
                {
                    Log.Info("SendNumber::First message is successfully processed and sent to cashflow: " + number);

                    SmsChatArguments dummyArguments = new SmsChatArguments()
                    {
                        Content = "bla"
                    };
                    SendSmsRequest smsRequest2 = new SendSmsRequest(RequestMode.Default,
                                                                    string.Empty,
                                                                    serviceConfiguration.PaymentConfiguration.PaymentCredentials.Username,                       // username
                                                                    serviceConfiguration.PaymentConfiguration.PaymentCredentials.Password,                       // password
                                                                    serviceConfiguration.PaymentConfiguration.BehaviorModel.Guid,                                //bm
                                                                    MobiContext.Service.ServiceData.Product.ExternalProductGuid,                                 //product
                                                                    serviceConfiguration.PaymentConfiguration.PaymentInterface.ExternalPaymentInterfaceGuid,     //interface
                                                                    MobiContext.Service.ServiceData.FallbackCountry.TwoLetterIsoCode,
                                                                    serviceConfiguration.PaymentConfiguration.PaymentProvider.ExternalPaymentProviderGuid.Value, //provider
                                                                    mobileOperator.ExternalMobileOperatorID.ToString(),
                                                                    number,
                                                                    "Ahojky,jestli hledas vzajemne porozumeni a prijemne chvilky travene ve dvou,tak to pises spravne:)Nechci uz byt na vsechno sama,jak jsi na tom ty?",
                                                                    Guid.NewGuid().ToString(), // "send sms ref."
                                                                    string.Empty,
                                                                    dummyArguments.ToMessageArguments());
                    SendSmsResponse response2 = client.SendSms(smsRequest2);

                    if (response2.Status.Code == MessageStatusCode.Success)
                    {
                        return(this.Json(new { status = true, message = "Vaše žádost byla úspěšně odeslána" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        Log.Error(string.Format("SendNumber::Cashflow returned us error on second message (SubCode='{0}', Message='{1}'",
                                                response.Status.SubCode.ToString(),
                                                response.Status.Message));
                        return(this.Json(new { status = false, message = Translations.Web.Error.ErrInternal }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    Log.Error(string.Format("SendNumber::Cashflow returned us error on first message (SubCode='{0}', Message='{1}'",
                                            response.Status.SubCode.ToString(),
                                            response.Status.Message));
                    return(this.Json(new { status = false, message = Translations.Web.Error.ErrInternal }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Log.Error("SendNumber::Cashflow returned us fatal error", e);
                return(this.Json(new { status = false, message = Translations.Web.Error.ErrInternal }, JsonRequestBehavior.AllowGet));
            }
        }
        protected override ShortMessageRequest LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             ShortMessageRequestTable.GetColumnNames("[smr]") +
                             (this.Depth > 0 ? "," + ShortMessageTable.GetColumnNames("[smr_sm]") : string.Empty) +
                             (this.Depth > 1 ? "," + ActionContextTable.GetColumnNames("[smr_sm_ac]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[smr_sm_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[smr_sm_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[smr_sm_c]") : string.Empty) +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[smr_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[smr_u_ut]") : string.Empty) +
                             " FROM [core].[ShortMessageRequest] AS [smr] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[ShortMessage] AS [smr_sm] ON [smr].[ShortMessageID] = [smr_sm].[ShortMessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ActionContext] AS [smr_sm_ac] ON [smr_sm].[ActionContextID] = [smr_sm_ac].[ActionContextID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [smr_sm_s] ON [smr_sm].[ServiceID] = [smr_sm_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [smr_sm_mo] ON [smr_sm].[MobileOperatorID] = [smr_sm_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Customer] AS [smr_sm_c] ON [smr_sm].[CustomerID] = [smr_sm_c].[CustomerID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[User] AS [smr_u] ON [smr].[UserID] = [smr_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserType] AS [smr_u_ut] ON [smr_u].[UserTypeID] = [smr_u_ut].[UserTypeID] ";
                }
                sqlCmdText += "WHERE [smr].[ShortMessageRequestID] = @ShortMessageRequestID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@ShortMessageRequestID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("smr", "loadinternal", "notfound"), "ShortMessageRequest could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                ShortMessageRequestTable smrTable       = new ShortMessageRequestTable(query);
                ShortMessageTable        smr_smTable    = (this.Depth > 0) ? new ShortMessageTable(query) : null;
                ActionContextTable       smr_sm_acTable = (this.Depth > 1) ? new ActionContextTable(query) : null;
                ServiceTable             smr_sm_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                MobileOperatorTable      smr_sm_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;
                CustomerTable            smr_sm_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                UserTable     smr_uTable    = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable smr_u_utTable = (this.Depth > 1) ? new UserTypeTable(query) : null;


                ActionContext       smr_sm_acObject = (this.Depth > 1) ? smr_sm_acTable.CreateInstance() : null;
                Service             smr_sm_sObject  = (this.Depth > 1) ? smr_sm_sTable.CreateInstance() : null;
                MobileOperator      smr_sm_moObject = (this.Depth > 1) ? smr_sm_moTable.CreateInstance() : null;
                Customer            smr_sm_cObject  = (this.Depth > 1) ? smr_sm_cTable.CreateInstance() : null;
                ShortMessage        smr_smObject    = (this.Depth > 0) ? smr_smTable.CreateInstance(smr_sm_acObject, smr_sm_sObject, smr_sm_moObject, smr_sm_cObject) : null;
                UserType            smr_u_utObject  = (this.Depth > 1) ? smr_u_utTable.CreateInstance() : null;
                User                smr_uObject     = (this.Depth > 0) ? smr_uTable.CreateInstance(smr_u_utObject) : null;
                ShortMessageRequest smrObject       = smrTable.CreateInstance(smr_smObject, smr_uObject);
                sqlReader.Close();

                return(smrObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("smr", "loadinternal", "exception"), "ShortMessageRequest could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "ShortMessageRequest", "Exception while loading ShortMessageRequest object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 13
0
        public ServiceConfigurationEntry Load(ISqlConnectionInfo connection, Service service, Country country, MobileOperator mobileOperator)
        {
            SqlQueryParameters parameters = new SqlQueryParameters();

            parameters.Where = "[sce].ServiceConfigurationID = @ServiceConfigurationID AND [sce].CountryID = @CountryID AND [sce].MobileOperatorID = @MobileOperatorID";
            parameters.Arguments.Add("ServiceConfigurationID", service.ServiceConfiguration.ID);
            parameters.Arguments.Add("CountryID", country.ID);
            parameters.Arguments.Add("MobileOperatorID", mobileOperator.ID);
            return(this.Load(connection, parameters));
        }
        public MobileOperatorCode Load(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             MobileOperatorCodeTable.GetColumnNames("[moc]") +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[moc_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[moc_mo_c]") : string.Empty) +
                             " FROM [core].[MobileOperatorCode] AS [moc] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[MobileOperator] AS [moc_mo] ON [moc].[MobileOperatorID] = [moc_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [moc_mo_c] ON [moc_mo].[CountryID] = [moc_mo_c].[CountryID] ";
                }


                parameters.Top = 1;
                sqlCmdText     = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("moc", "customload", "notfound"), "MobileOperatorCode could not be loaded using custom logic as it was not found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MobileOperatorCodeTable mocTable      = new MobileOperatorCodeTable(query);
                MobileOperatorTable     moc_moTable   = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable            moc_mo_cTable = (this.Depth > 1) ? new CountryTable(query) : null;


                Country            moc_mo_cObject = (this.Depth > 1) ? moc_mo_cTable.CreateInstance() : null;
                MobileOperator     moc_moObject   = (this.Depth > 0) ? moc_moTable.CreateInstance(moc_mo_cObject) : null;
                MobileOperatorCode mocObject      = mocTable.CreateInstance(moc_moObject);
                sqlReader.Close();

                return(mocObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("moc", "customload", "exception"), "MobileOperatorCode could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "MobileOperatorCode", "Exception while loading (custom/single) MobileOperatorCode object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 15
0
        public List <Customer> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_mo_c].[CountryID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "customloadmany", "notfound"), "Customer list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <Customer>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;

                List <Customer> result = new List <Customer>();
                do
                {
                    UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                    User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                    Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                    Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                    Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                    ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                    UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                    Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                    Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                    ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                    Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                    Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                    Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                    Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                    Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                    Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                    MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                    Customer             cObject       = (this.Depth > -1) ? cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject) : null;
                    result.Add(cObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "customloadmany", "exception"), "Customer list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Customer", "Exception while loading (custom/many) Customer object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 16
0
 public ShortMessage CreateInstance(ActionContext actionContext, Service service, MobileOperator mobileOperator, Customer customer)
 {
     if (!this.HasData)
     {
         return(null);
     }
     return(new ShortMessage(this.ShortMessageID, this.ShortMessageGuid, actionContext ?? (this.ActionContextID.HasValue ? new ActionContext(this.ActionContextID.Value) : null), service ?? (this.ServiceID.HasValue ? new Service(this.ServiceID.Value) : null), mobileOperator ?? (this.MobileOperatorID.HasValue ? new MobileOperator(this.MobileOperatorID.Value) : null), customer ?? new Customer(this.CustomerID), (ShortMessageDirection)this.ShortMessageDirectionID, (ShortMessageStatus)this.ShortMessageStatusID, this.Text, this.Shortcode, this.Keyword, this.Updated, this.Created));
 }
Esempio n. 17
0
        public List <MOMessage> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             MOMessageTable.GetColumnNames("[mom]") +
                             (this.Depth > 0 ? "," + MessageTable.GetColumnNames("[mom_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[mom_m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[mom_m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[mom_m_mo]") : string.Empty) +
                             " FROM [stats].[MOMessage] AS [mom] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [stats].[Message] AS [mom_m] ON [mom].[MessageID] = [mom_m].[MessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [mom_m_s] ON [mom_m].[ServiceID] = [mom_m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [mom_m_c] ON [mom_m].[CustomerID] = [mom_m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [mom_m_mo] ON [mom_m].[MobileOperatorID] = [mom_m_mo].[MobileOperatorID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "customloadmany", "notfound"), "MOMessage list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <MOMessage>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MOMessageTable      momTable      = new MOMessageTable(query);
                MessageTable        mom_mTable    = (this.Depth > 0) ? new MessageTable(query) : null;
                ServiceTable        mom_m_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                CustomerTable       mom_m_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                MobileOperatorTable mom_m_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;

                List <MOMessage> result = new List <MOMessage>();
                do
                {
                    Service        mom_m_sObject  = (this.Depth > 1) ? mom_m_sTable.CreateInstance() : null;
                    Customer       mom_m_cObject  = (this.Depth > 1) ? mom_m_cTable.CreateInstance() : null;
                    MobileOperator mom_m_moObject = (this.Depth > 1) ? mom_m_moTable.CreateInstance() : null;
                    Message        mom_mObject    = (this.Depth > 0) ? mom_mTable.CreateInstance(mom_m_sObject, mom_m_cObject, mom_m_moObject) : null;
                    MOMessage      momObject      = (this.Depth > -1) ? momTable.CreateInstance(mom_mObject) : null;
                    result.Add(momObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "customloadmany", "exception"), "MOMessage list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "MOMessage", "Exception while loading (custom/many) MOMessage object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 18
0
        private static void Main(string[] args)
        {
            int choiceMenu = 0;
            int choiceProg = 0;

            List <MobileOperator> mobileOperators = new List <MobileOperator>();
            List <Person>         persons         = new List <Person>();

            //Object to Bussiness Layer

            MobileOperatorManagementSystemBussinessLayerClass MobileOperatorManagementSystemBussinessLayerObj = new MobileOperatorManagementSystemBussinessLayerClass();

            do
            {
                Console.WriteLine("====================================");
                Console.WriteLine("  MOBILE OPERATOR MANAGEMENT SYSTEM  ");
                Console.WriteLine("=====================================");
                Console.WriteLine("Press 1 to add New Mobile Operator");
                Console.WriteLine("Press 2 to Display all Mobile Operators");
                Console.WriteLine("Press 3 to add New Person");
                Console.WriteLine("Press 4 to Display two mobile Operators by Rating");
                Console.WriteLine("Press 5 to Serach Person with mobile Operator using Person Id");
                Console.WriteLine("Press 6 to display person with id,name,operator name and write it to text file");
                Console.WriteLine("Enter Your Choice:");

                try
                {
                    choiceMenu = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                switch (choiceMenu)
                {
                case 1:

                    //Getting Mobile Operators Details
                    Console.WriteLine("Enter Mobile Operator Name :");
                    string mobileOperatorName = Console.ReadLine();

                    Console.WriteLine("Enter Rating :");
                    int rating = Convert.ToInt32(Console.ReadLine());

                    MobileOperator newMobileOperator = MobileOperatorManagementSystemBussinessLayerObj.AddMobileOperator(mobileOperatorName, rating, mobileOperators);

                    if (newMobileOperator != null)
                    {
                        mobileOperators.Add(newMobileOperator);
                        Console.WriteLine("New Mobile Operator Added");
                        mobileOperators.Add(newMobileOperator);
                    }
                    else
                    {
                        Console.WriteLine("Error in Adding New Mobile Operator");
                    }
                    break;

                case 2:

                    DataTable dtblMobileOperators = MobileOperatorManagementSystemBussinessLayerObj.GetMobileOperatorDetails();

                    foreach (DataRow dataRow in dtblMobileOperators.Rows)
                    {
                        Console.WriteLine("|{0}\t|{1}|\t{2}", (int)dataRow["id"], (string)dataRow["name"], (int)dataRow["rating"]);
                    }

                    break;

                case 3:

                    Console.WriteLine("Enter Person Name:");
                    string personName = Console.ReadLine();

                    Console.WriteLine("Enter Mobile Operator ID:");
                    int mobileOperatorId = Convert.ToInt32(Console.ReadLine());

                    Person newPerson = MobileOperatorManagementSystemBussinessLayerObj.AddPerson(personName, mobileOperatorId);

                    if (newPerson != null)
                    {
                        Console.WriteLine("New Person Added Successfully");
                        persons.Add(newPerson);
                    }
                    else
                    {
                        Console.WriteLine("Error in Adding New Person");
                    }

                    break;

                case 4:

                    DataTable dtbleTopMobileOperators = MobileOperatorManagementSystemBussinessLayerObj.GetTopTwoMobileOperators();

                    foreach (DataRow dataRow in dtbleTopMobileOperators.Rows)
                    {
                        Console.WriteLine("|{0}", (string)dataRow["name"]);
                    }

                    break;

                case 5:

                    Console.WriteLine("Enter ID :");
                    int     id   = -1;
                    Boolean flag = false;

                    try
                    {
                        id = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    DataTable personRecord = MobileOperatorManagementSystemBussinessLayerObj.SearchPerson(id);

                    foreach (DataRow dataRow in personRecord.Rows)
                    {
                        flag = true;
                        Console.WriteLine("|{0}\t|{1}|\t{2}", (int)dataRow["id"], (string)dataRow["Name"], (int)dataRow["mobileOperatorId"]);
                    }

                    if (flag != true)
                    {
                        Console.WriteLine("No pErson Found.....");
                    }

                    break;

                case 6:

                    DataTable dtblAllPersons = MobileOperatorManagementSystemBussinessLayerObj.GetAllPersonDetails();

                    foreach (DataRow dataRow in dtblAllPersons.Rows)
                    {
                        Console.WriteLine("|{0}\t|{1}|\t{2}", (int)dataRow["id"], (string)dataRow["Name"], (int)dataRow["mobileOperatorId"]);
                    }

                    MobileOperatorManagementSystemBussinessLayerObj.WritePersonsDetailsTotxt(dtblAllPersons);

                    break;

                default:
                    Console.WriteLine("Wrong Choice");
                    break;
                }

                Console.WriteLine("Press 1 to continue ");
                try
                {
                    choiceProg = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            } while (choiceProg == 1);
        }
        private static void Main(string[] args)
        {
            int choiceMenu = 0;
            int choiceProg = 0;

            List <MobileOperator> mobileOperators = new List <MobileOperator>(); //To Store Mobile Operators
            List <Person>         persons         = new List <Person>();         //To Store Persons

            //Object to Bussiness Layer
            MobileOperatorBussinessLayer mobileOperatorBussinessLayer = new MobileOperatorBussinessLayer();

            do
            {
                //Menu
                Console.WriteLine("====================================");
                Console.WriteLine("  MOBILE OPERATOR MANAGEMENT SYSTEM  ");
                Console.WriteLine("=====================================");
                Console.WriteLine("Press 1 to add New Mobile Operator");
                Console.WriteLine("Press 2 to Display all Mobile Operators");
                Console.WriteLine("Press 3 to add New Person");
                Console.WriteLine("Press 4 to Display two mobile Operators by Rating");
                Console.WriteLine("Press 5 to Serach Person with mobile Operator using Person Id");
                Console.WriteLine("Press 6 to display person with id,name,operator name and write it to text file");
                Console.WriteLine("Enter Your Choice:");

                try
                {
                    choiceMenu = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                switch (choiceMenu)
                {
                case 1:

                    //Getting Mobile Operators Details
                    MobileOperator mobileOperator = new MobileOperator();

                    Console.WriteLine("Enter Mobile Operator Name :");
                    mobileOperator.Name = Console.ReadLine();

                    Console.WriteLine("Enter Rating :");
                    mobileOperator.Rating = Convert.ToInt32(Console.ReadLine());

                    MobileOperator newMobileOperator = null;

                    try
                    {
                        newMobileOperator = mobileOperatorBussinessLayer.AddMobileOperator(mobileOperator, mobileOperators);
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }

                    if (newMobileOperator != null)
                    {
                        mobileOperators.Add(newMobileOperator);
                        Console.WriteLine("New Mobile Operator Added");
                    }
                    else
                    {
                        Console.WriteLine("Error in Adding New Mobile Operator");
                    }
                    break;

                case 2:

                    List <MobileOperator> mobileOperatorsDetails = new List <MobileOperator>();       //Get All Details of all Mobile Operators

                    try
                    {
                        mobileOperatorsDetails = mobileOperatorBussinessLayer.GetMobileOperatorDetails();
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }

                    //Printing the Mobile Operators details
                    foreach (MobileOperator mobileOperatorIterator in mobileOperatorsDetails)
                    {
                        Console.WriteLine("{0},{1},{2}", mobileOperatorIterator.Id, mobileOperatorIterator.Name, mobileOperatorIterator.Rating);
                    }

                    break;

                case 3:

                    Person person = new Person();

                    Console.WriteLine("Enter Person Name:");
                    person.Name = Console.ReadLine();

                    Console.WriteLine("Enter Mobile Operator ID:");
                    person.MobileOperatorId = Convert.ToInt32(Console.ReadLine());

                    //To object to add new Person
                    Person newPerson = new Person();

                    try
                    {
                        newPerson = mobileOperatorBussinessLayer.AddPerson(person);
                        persons.Add(newPerson);
                        Console.WriteLine("New Person Added Successfully");
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }

                    break;

                case 4:

                    List <MobileOperator> topMobileOperators = new List <MobileOperator>();

                    try
                    {
                        topMobileOperators = mobileOperatorBussinessLayer.GetTopTwoMobileOperators();
                        foreach (MobileOperator mobileOperatorIterator in topMobileOperators)
                        {
                            Console.WriteLine("{0},{1},{2}", mobileOperatorIterator.Id, mobileOperatorIterator.Name, mobileOperatorIterator.Rating, mobileOperatorIterator.Rating);
                        }
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }

                    break;

                case 5:

                    Console.WriteLine("Enter ID :");
                    int id = 0;

                    try
                    {
                        id = Convert.ToInt32(Console.ReadLine());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    Person personDetails = mobileOperatorBussinessLayer.GetPersonRecord(id);

                    if (personDetails.PersonId != 0)
                    {
                        Console.WriteLine("{0},{1},{2}", personDetails.PersonId, personDetails.Name, personDetails.MobileOperatorId);
                    }
                    else
                    {
                        Console.WriteLine("PERSON DOESN'T EXIST");
                    }
                    break;

                case 6:

                    List <Person> personsDetails = new List <Person>();
                    try
                    {
                        personsDetails = mobileOperatorBussinessLayer.GetAllPersonDetails();
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }

                    foreach (Person personIterator in personsDetails)
                    {
                        Console.WriteLine("{0},{1},{2}", personIterator.PersonId, personIterator.Name, personIterator.MobileOperatorId);
                    }

                    try
                    {
                        mobileOperatorBussinessLayer.WritePersonsDetailsToFile(personsDetails);
                    }
                    catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }
                    break;

                default:
                    Console.WriteLine("Wrong Choice");
                    break;
                }

                Console.WriteLine("Press 1 to continue ");
                try
                {
                    choiceProg = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            } while (choiceProg == 1);
        }
Esempio n. 20
0
		public Customer CreateInstance(User user, Service service, Country country, Language language, MobileOperator mobileOperator)  
		{ 
			if (!this.HasData) return null;
			return new Customer(this.CustomerID,this.CustomerGuid,user ?? (this.UserID.HasValue ? new User(this.UserID.Value) : null), service ?? new Service(this.ServiceID), country ?? new Country(this.CountryID), language ?? (this.LanguageID.HasValue ? new Language(this.LanguageID.Value) : null), mobileOperator ?? (this.MobileOperatorID.HasValue ? new MobileOperator(this.MobileOperatorID.Value) : null), this.Msisdn,this.EncryptedMsisdn,this.Updated,this.Created); 
		}
Esempio n. 21
0
        public async Task <IActionResult> Istifadechininmelumatlari(AccountDetailsViewModel accountDetailsViewModel)
        {
            string     activeUserName   = User.Identity.Name;
            CustomUser customUserFromDb = await _userManager.FindByNameAsync(activeUserName);

            if (customUserFromDb == null)
            {
                return(View("Views/Xeta/Index.cshtml"));
            }

            MobileOperator mobileOperatorFromDb = _context.MobileOperators.FirstOrDefault(mo => mo.Id == accountDetailsViewModel.MobileOperatorId);

            if (!ModelState.IsValid)
            {
                ViewBag.FirstName = customUserFromDb.FirstName;
                ViewBag.LastName  = customUserFromDb.LastName;
                ViewBag.Email     = customUserFromDb.Email;
                ViewBag.SelectedMobileOperatorId = customUserFromDb.MobileOperatorId;
                ViewBag.PhoneNumber     = customUserFromDb.PhoneNumber.Substring(6, 7);
                ViewBag.MobileOperators = _context.MobileOperators;
                return(View(accountDetailsViewModel));
            }

            string customUserFromDbOldEmail = customUserFromDb.Email;

            customUserFromDb.FirstName        = accountDetailsViewModel.FirstName.Trim();
            customUserFromDb.LastName         = accountDetailsViewModel.LastName.Trim();
            customUserFromDb.UserName         = accountDetailsViewModel.Email.Trim();
            customUserFromDb.Email            = accountDetailsViewModel.Email.Trim();
            customUserFromDb.MobileOperatorId = accountDetailsViewModel.MobileOperatorId;
            customUserFromDb.PhoneNumber      = mobileOperatorFromDb.MobileOperatorCode + accountDetailsViewModel.PhoneNumber.Trim();
            await _userManager.UpdateAsync(customUserFromDb);

            if (customUserFromDb.Email != customUserFromDbOldEmail)
            {
                customUserFromDb.EmailConfirmed = false;
            }
            await _userManager.UpdateAsync(customUserFromDb);

            if (accountDetailsViewModel.CurrentPassword != null && accountDetailsViewModel.NewPassword != null)
            {
                string replacedCurrentPassword = accountDetailsViewModel.CurrentPassword.Trim();
                string replacedNewPassword     = accountDetailsViewModel.NewPassword.Trim();

                IdentityResult result = await _userManager.ChangePasswordAsync(customUserFromDb, replacedCurrentPassword, replacedNewPassword);

                await _userManager.UpdateAsync(customUserFromDb);

                if (!result.Succeeded)
                {
                    ViewBag.FirstName = customUserFromDb.FirstName;
                    ViewBag.LastName  = customUserFromDb.LastName;
                    ViewBag.Email     = customUserFromDb.Email;
                    ViewBag.SelectedMobileOperatorId = customUserFromDb.MobileOperatorId;
                    ViewBag.PhoneNumber     = customUserFromDb.PhoneNumber.Substring(6, 7);
                    ViewBag.MobileOperators = _context.MobileOperators;
                    ViewBag.MobileOperators = _context.MobileOperators;
                    ModelState.AddModelError("CurrentPassword", "Hazırki şifrə yanlışdır və ya yeni şifrə tələblərə uyğun deyil.");
                    ModelState.AddModelError("NewPassword", "Hazırki şifrə yanlışdır və ya yeni şifrə tələblərə uyğun deyil.");
                    return(View(accountDetailsViewModel));
                }
            }

            if (accountDetailsViewModel.UploadFile != null)
            {
                if (accountDetailsViewModel.UploadFile.ContentType.Contains("image/jpg") || accountDetailsViewModel.UploadFile.ContentType.Contains("image/jpeg"))
                {
                    if (accountDetailsViewModel.UploadFile.Length > (2 * 1024 * 1024))
                    {
                        ViewBag.FirstName = customUserFromDb.FirstName;
                        ViewBag.LastName  = customUserFromDb.LastName;
                        ViewBag.Email     = customUserFromDb.Email;
                        ViewBag.SelectedMobileOperatorId = customUserFromDb.MobileOperatorId;
                        ViewBag.PhoneNumber     = customUserFromDb.PhoneNumber.Substring(6, 7);
                        ViewBag.MobileOperators = _context.MobileOperators;
                        ViewBag.MobileOperators = _context.MobileOperators;
                        ModelState.AddModelError("", "Şəklin həcmi 2MB'dan çox ola bilməz.");
                        return(View(accountDetailsViewModel));
                    }

                    string folderPath = Path.Combine(_env.WebRootPath, "MainPageFiles", "images", "users");
                    fileName = Guid.NewGuid().ToString() + "_istifadechi_" + accountDetailsViewModel.UploadFile.FileName;
                    string filePath = Path.Combine(folderPath, fileName);

                    //Deleting profile picture of the user from file system
                    string customUserFromDbFilePath = Path.Combine(_env.WebRootPath, "MainPageFiles", "images", "users", customUserFromDb.ProfilePictureURL);
                    if (System.IO.File.Exists(customUserFromDbFilePath))
                    {
                        try
                        {
                            System.IO.File.Delete(customUserFromDbFilePath);
                        }
                        catch
                        {
                            ModelState.AddModelError("UploadFile", "Xəta baş verdi");
                            return(View(accountDetailsViewModel));
                        }
                    }

                    using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
                    {
                        await accountDetailsViewModel.UploadFile.CopyToAsync(fileStream);
                    }
                    customUserFromDb.ProfilePictureURL = fileName;
                    await _context.SaveChangesAsync();
                }
                else
                {
                    ViewBag.FirstName = customUserFromDb.FirstName;
                    ViewBag.LastName  = customUserFromDb.LastName;
                    ViewBag.Email     = customUserFromDb.Email;
                    ViewBag.SelectedMobileOperatorId = customUserFromDb.MobileOperatorId;
                    ViewBag.PhoneNumber     = customUserFromDb.PhoneNumber.Substring(6, 7);
                    ViewBag.MobileOperators = _context.MobileOperators;
                    ViewBag.MobileOperators = _context.MobileOperators;
                    ModelState.AddModelError("", "Zəhmət olmasa, tələb olunan formatda şəkil yükləyin");
                    return(View(accountDetailsViewModel));
                }
            }

            string emailConfirmationToken = await _userManager.GenerateEmailConfirmationTokenAsync(customUserFromDb);

            if (customUserFromDb.EmailConfirmed == false)
            {
                #region Sending Email Confirmation Message
                string messageSubject = "Hesabın(Yeni email ünvanı) təsdiqlənməsi";
                string messageBody    = $"<table style='width:100%;background-color:#292C34;padding:50px'><thead style ='width:100%;display:flex;justify-content:center;'><tr style ='width:100%;display:flex;justify-content:center;'><th style ='width:100%;color:#F9F9F9;font-family:Roboto, sans-serif;font-weight:400;font-size:50px'>Kirayeemlak.az</th></tr><thead><tbody><tr><td style ='padding:30px 0px;color:#888888;font-family:Roboto Condensed, sans-serif;font-size:20px;'>Hörmətli istifadəçi, yeni email ünvanınız uğurla qeydiyyatdan keçdi. Hesabınızı təsdiqləmək üçün aşağıdakı 'Hesabını təsdiqlə' düyməsinə tıklayın.</td></tr><tr><td style ='font-family:Roboto Condensed, sans-serif;text-align:center;'><a href='http://kirayemlak.az/Hesab/Tesdiqetme?userId={customUserFromDb.Id}&emailConfirmationToken={emailConfirmationToken}' style ='text-decoration:none;padding:10px 30px;border-radius:3px;background-color:#F9F9F9;color:#292C34;font-weight:lighter;font-size:20px;cursor:pointer;'>Hesabını təsdiqlə</a></td></tr></tbody></table>";
                await UtilityRealEstate.SendMessage(_configuration, accountDetailsViewModel.Email, messageSubject, messageBody, customUserFromDb, customUserFromDb, emailConfirmationToken);

                #endregion
            }

            TempData["AccountDetailsUpdated"] = true;

            ViewBag.FirstName = customUserFromDb.FirstName;
            ViewBag.LastName  = customUserFromDb.LastName;
            ViewBag.Email     = customUserFromDb.Email;
            ViewBag.SelectedMobileOperatorId = customUserFromDb.MobileOperatorId;
            ViewBag.PhoneNumber     = customUserFromDb.PhoneNumber.Substring(6, 7);
            ViewBag.MobileOperators = _context.MobileOperators;

            return(View());
        }
Esempio n. 22
0
 public Message(int id, Guid guid, int?externalID, Service service, Customer customer, string mobileOperatorName, MobileOperator mobileOperator, MessageDirection messageDirection, MessageType messageType, MessageStatus messageStatus, string text, int?shorcode, string keyword, int?trackingID, DateTime updated, DateTime created) : base(id, updated, created, false)
 {
     this._guid               = guid;
     this._externalID         = externalID;
     this._service            = service;
     this._customer           = customer;
     this._mobileOperatorName = mobileOperatorName;
     this._mobileOperator     = mobileOperator;
     this._messageDirection   = messageDirection;
     this._messageType        = messageType;
     this._messageStatus      = messageStatus;
     this._text               = text;
     this._shorcode           = shorcode;
     this._keyword            = keyword;
     this._trackingID         = trackingID;
 }
Esempio n. 23
0
        protected override Customer LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_mo_c].[CountryID] ";
                }
                sqlCmdText += "WHERE [c].[CustomerID] = @CustomerID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@CustomerID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "notfound"), "Customer could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;


                UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                Customer             cObject       = cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject);
                sqlReader.Close();

                return(cObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "exception"), "Customer could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Customer", "Exception while loading Customer object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 24
0
        public ServiceConfigurationEntry Load(IConnectionInfo connection, Service service, Country country, MobileOperator mobileOperator)
        {
            ISqlConnectionInfo sqlConnection = connection as ISqlConnectionInfo;

            if (sqlConnection != null)
            {
                return(this.Load(sqlConnection, service, country, mobileOperator));
            }
            using (sqlConnection = new SqlConnectionInfo(connection, this.Type))
                return(this.Load(sqlConnection, service, country, mobileOperator));
        }
Esempio n. 25
0
 public MobileAccountWithMemo(MobileOperator mobileOperator, int number) :
     base(mobileOperator, number)
 {
 }
Esempio n. 26
0
 public MobileOperatorViewModel(MobileOperator mobileOperator)
 {
     ID   = mobileOperator.ID;
     Name = mobileOperator.Name;
 }
Esempio n. 27
0
        protected override MOMessage LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             MOMessageTable.GetColumnNames("[mom]") +
                             (this.Depth > 0 ? "," + MessageTable.GetColumnNames("[mom_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[mom_m_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + CustomerTable.GetColumnNames("[mom_m_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + MobileOperatorTable.GetColumnNames("[mom_m_mo]") : string.Empty) +
                             " FROM [stats].[MOMessage] AS [mom] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [stats].[Message] AS [mom_m] ON [mom].[MessageID] = [mom_m].[MessageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [mom_m_s] ON [mom_m].[ServiceID] = [mom_m_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Customer] AS [mom_m_c] ON [mom_m].[CustomerID] = [mom_m_c].[CustomerID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [mom_m_mo] ON [mom_m].[MobileOperatorID] = [mom_m_mo].[MobileOperatorID] ";
                }
                sqlCmdText += "WHERE [mom].[MOMessageID] = @MOMessageID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@MOMessageID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "loadinternal", "notfound"), "MOMessage could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                MOMessageTable      momTable      = new MOMessageTable(query);
                MessageTable        mom_mTable    = (this.Depth > 0) ? new MessageTable(query) : null;
                ServiceTable        mom_m_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                CustomerTable       mom_m_cTable  = (this.Depth > 1) ? new CustomerTable(query) : null;
                MobileOperatorTable mom_m_moTable = (this.Depth > 1) ? new MobileOperatorTable(query) : null;


                Service        mom_m_sObject  = (this.Depth > 1) ? mom_m_sTable.CreateInstance() : null;
                Customer       mom_m_cObject  = (this.Depth > 1) ? mom_m_cTable.CreateInstance() : null;
                MobileOperator mom_m_moObject = (this.Depth > 1) ? mom_m_moTable.CreateInstance() : null;
                Message        mom_mObject    = (this.Depth > 0) ? mom_mTable.CreateInstance(mom_m_sObject, mom_m_cObject, mom_m_moObject) : null;
                MOMessage      momObject      = momTable.CreateInstance(mom_mObject);
                sqlReader.Close();

                return(momObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("mom", "loadinternal", "exception"), "MOMessage could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "MOMessage", "Exception while loading MOMessage object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 28
0
 public MobileAccountWithMemo(MobileOperator mobileOperator) :
     base(mobileOperator)
 {
 }
Esempio n. 29
0
 /// <summary>
 /// Выводит найденого мобильного оператора.
 /// </summary>
 /// <param name="mobileOperator">Мобильный оператор.</param>
 /// <returns>Эквивалентный строковый код.</returns>
 public static string Find(MobileOperator mobileOperator) => TryFind(mobileOperator, out string mo) ? mo : throw new FormatException();
Esempio n. 30
0
 public ServiceConfigurationEntry Load(Service service, Country country, MobileOperator mobileOperator)
 {
     using (SqlConnectionInfo connection = new SqlConnectionInfo(this.Type))
         return(this.Load(connection, service, country, mobileOperator));
 }