예제 #1
0
        public List<Settings> GetSettings(int ClientId)
        {
            ClientRepository clientrep = new ClientRepository();
            List<Settings> lsSettingsList = new List<Settings>();
            Settings ins;

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI;

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Settings WHERE ClientId=" + ClientId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Settings();
                    ins.SettingId = Convert.ToInt32(drI["SettingId"]);
                    ins.Setting = drI["Setting"].ToString();
                    ins.Value = drI["Value"].ToString();
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    lsSettingsList.Add(ins);
                }
            }

            foreach (Settings setting in lsSettingsList)
            {
                setting.ClientName = clientrep.GetClient(setting.ClientId).Name;
            }

            drI.Close();
            con.Close();

            return lsSettingsList;
        }
예제 #2
0
        public JsonResult RegisterUser(int ClientId, string NameSurname, string Email, string Password, string Phone, string DeviceId, string RawPW, string Address)
        {
            DeviceUser newUser = new DeviceUser(ClientId, DeviceId, NameSurname, Phone, Email, Password, Address);
            Client c = new Client();
            ClientRepository cr = new ClientRepository();
            c = cr.GetClient(Convert.ToInt32(ClientId));

            if (appRep.CheckDeviceUserRegistration(DeviceId, Phone, ClientId.ToString(), Password))
            {
                newUser.DeviceUserId = -1;
                var j = this.Json(newUser);
                return Json(j, JsonRequestBehavior.AllowGet);
            }
            else
            {
                //* In app, check if the DeviceUserId field != 0 for a successfull registration *//
                DeviceUser insertedUser = appRep.AddDeviceUser(newUser);

                if (insertedUser.DeviceUserId != 0)
                {
                    Functions f = new Functions();
                    f.SendEmail("You have been successfully registered. \n Registration details: \n Phone: " + Phone + " \n Password: "******"\n\n Please keep this information safe, and do not delete this email.", Email, "Registration Details for: " + c.Name);

                    //...Send Email to Registrar
                    //Get Client Service Mail List
                    List<Settings> mails = setRep.GetSettings("registrar", ClientId);

                    if (mails.Count >= 1)
                    {
                        StringBuilder maillist = new StringBuilder();

                        foreach (Settings setting in mails)
                        {
                            maillist.Append(setting.Value).Append(",");
                        }
                        maillist.Remove(maillist.Length - 1, 1);

                        f.SendEmail("Please Approve:\n"+NameSurname, maillist.ToString(), "Netintercom User Request's Approval");
                    }
                }

                var j = this.Json(newUser);
                return Json(j, JsonRequestBehavior.AllowGet);
            }
        }