Пример #1
0
    public static RegInfo SearchSingleRecord(String uid)
    {
        SqlConnection con    = null;
        RegInfo       regobj = new RegInfo();

        try
        {
            con = DBLogic.GetConnection();
            con.Open();
            String query = "select * from reg where userid = '" + uid + "'";

            SqlCommand com = new SqlCommand(query, con);

            SqlDataReader dr = com.ExecuteReader();

            dr.Read();

            regobj.UserId  = dr[0].ToString();
            regobj.Pass    = dr[1].ToString();
            regobj.EmailId = dr[2].ToString();
        }
        catch (Exception err)
        {
            //Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
        return(regobj);
    }
Пример #2
0
        public static bool InsertCompConfig(Models.BLModel.CompConfig model, out string message)
        {
            message = null;
            if (model.CPU == 0)
            {
                message = "Comp Config is empty";
                return(false);
            }
            Models.DBModel.CompConfig config = new Models.DBModel.CompConfig
            {
                CPU       = model.CPU,
                RAM       = model.RAM,
                VideoCard = model.VideoCard,
                OS        = model.OS
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertCompConfig(config);

            if (!result)
            {
                message = "Comp Config  is not added";
            }
            return(true);
        }
Пример #3
0
 public void PostInsert([FromBody] WebUser wu)
 {
     if (wu != null)
     {
         DBLogic.WebUserRegister(wu);
     }
 }
Пример #4
0
        public static bool InsertGameCatalog(Models.BLModel.GameCatalog model, out string message)
        {
            message = null;
            if (string.IsNullOrEmpty(model.Name))
            {
                message = "Game Catalog is empty";
                return(false);
            }
            Models.DBModel.GameCatalog video = new Models.DBModel.GameCatalog
            {
                Name         = model.Name,
                Price        = model.Price,
                DescribeGame = model.DescribeGame,
                TypeGame     = model.TypeGame,
                Url          = model.Url,
                Key          = model.Key
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertGameCatalog(video);

            if (!result)
            {
                message = " Game Catalog  is not added";
            }
            return(true);
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    DBLogic.InsertWalletToNewUser(user.Id);
                    DBLogic.InsertBasketToNewUser(user.Id);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = DBLogic.GetConnection();

            con.Open();
            //build a query
            String     query = "update reg set password = '******' ,emailid='" + txtemail.Text + "'  where userid = '" + txtuserid.Text + "'";
            SqlCommand com   = new SqlCommand(query, con);

            //call the method of command object
            int result = com.ExecuteNonQuery();

            if (result > 0)
            {
                Label4.Text = "Record is UPDATED successfully";
            }
        }
        catch (Exception err)
        {
            Label4.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Пример #7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {//Default list of 5 last requests on load
            var lcslist = DBLogic.DBGetter();
            var border  = new BorderCreate();

            for (int i = 0; i < lcslist.Count(); i++)
            {
                borders.Add(border.createUpperBorder(i, $"Strings: \"{lcslist[i].FirstString}\" + \"{lcslist[i].SecondString}\"", MainGrid));
                borders.Add(border.createBottomBorder(i, $"Answer: \"{lcslist[i].AnswerString}\"", MainGrid));
            }
        }
Пример #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DataTable dt = DBLogic.FetchAllRecord();
         DropDownList1.DataSource     = dt;
         DropDownList1.DataTextField  = "userid";
         DropDownList1.DataValueField = "userid";
         DropDownList1.DataBind();
     }
 }
Пример #9
0
 public IActionResult Index(string id)
 {
     if (id == null)
     {
         ClaimsPrincipal currentUser = this.User;
         id = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;
     }
     using (DBLogic db = new DBLogic(context))
     {
         return(View(db.LoadCompany(id)));
     }
 }
Пример #10
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable dt = DBLogic.FetchAllRecord();

        GridView1.DataSource = dt;
        GridView1.DataBind();

        /*  SqlConnection con = null;
         * try
         * {
         *    con = DBLogic.GetConnection();
         *
         *    String query = "select * from reg ";
         *
         *    //create the SqlDataAdapter object
         *    SqlDataAdapter da = new SqlDataAdapter(query, con);
         *
         *    //create the object Dataset
         *    DataSet ds = new DataSet();
         *
         *    //Call the fill Method and pass the
         *    //DataSet object
         *    da.Fill(ds);
         *
         *    //get the no of tables dataset contains
         *    DataTable dt = ds.Tables[0];
         *
         *    //bind the dataset table with the GridView
         *    GridView1.DataSource = dt;
         *    GridView1.DataBind();
         * }
         * catch (Exception err)
         * {
         *    Label1.Text = err.Message;
         * }
         * finally
         * {
         *    if (con != null)
         *    {
         *        con.Close();
         *    }
         * }*/
    }
Пример #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String uid = (String)Session["uid"];

            RegInfo regobj = DBLogic.SearchSingleRecord(uid);

            txtuserid.Text = regobj.UserId;
            txtpass.Text   = regobj.Pass;
            txtemail.Text  = regobj.EmailId;
        }
        else
        {
            txtuserid.Text = "";
            txtpass.Text   = "";
            txtemail.Text  = "";
        }
    }
Пример #12
0
        public IActionResult Index(int page = 1)
        {
            using (var db = new DBLogic(context))
            {
                int pageSize = 5;   // количество элементов на странице

                IEnumerable <Company> source = db.LoadCompany();
                var count = source.Count();
                var items = source.Skip((page - 1) * pageSize).Take(pageSize);

                PageViewModel    pageViewModel = new PageViewModel(count, page, pageSize);
                CompanyViewModel viewModel     = new CompanyViewModel
                {
                    PageViewModel = pageViewModel,
                    Company       = items
                };


                return(View(viewModel));
            }
        }
Пример #13
0
        private List <Border> borders = new List <Border>();//List of dynamic created borderboxes

        private void Accept_Button_Click(object sender, RoutedEventArgs e)
        {
            if (DesktopLogic.checkAcception(Str1TextBox, Str2TextBox))//if we typed smth
            {
                var border = new BorderCreate();
                DesktopLogic.clearBorders(borders, MainGrid);
                DBLogic.DBSetter(Str1TextBox.Text, Str2TextBox.Text);
                var lcslist = DBLogic.DBGetter();//Sending data to DB and making answer Borderbox visible
                AnswerBox.Visibility = Visibility.Visible;
                AnswerText.Text      = $"Answer:  \"{lcslist.FirstOrDefault().AnswerString}\" ";
                for (int i = 0; i < lcslist.Count(); i++)
                {
                    borders.Add(border.createUpperBorder(i, $"Strings: \"{lcslist[i].FirstString}\" + \"{lcslist[i].SecondString}\"", MainGrid));
                    borders.Add(border.createBottomBorder(i, $"Answer: \"{lcslist[i].AnswerString}\"", MainGrid));
                }
            }
            else
            {
                MessageBox.Show("Please enter correct values", "Error");//If we don't enter anything
            }
        }
Пример #14
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlConnection con = null;

        Label1.Text = DropDownList1.SelectedValue;
        try
        {
            con = DBLogic.GetConnection();

            String query = "select * from reg where userid = '" + DropDownList1.SelectedValue + "'";

            //create the SqlDataAdapter object
            SqlDataAdapter da = new SqlDataAdapter(query, con);

            //create the object Dataset
            DataSet ds = new DataSet();

            //Call the fill Method and pass the
            //DataSet object
            da.Fill(ds);

            //get the no of tables dataset contains
            DataTable dt = ds.Tables[0];

            //bind the dataset table with the GridView
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception err)
        {
            Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Пример #15
0
        public static bool InsertRam(Models.BLModel.Ram model, out string message)
        {
            message = null;
            if (model.SizeRam == 0)
            {
                message = "Ram is empty";
                return(false);
            }
            Models.DBModel.Ram ram = new Models.DBModel.Ram
            {
                SizeRam = model.SizeRam
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertRam(ram);

            if (!result)
            {
                message = "Ram  is not added";
            }
            return(true);
        }
Пример #16
0
        public static bool InsertTypeGame(Models.BLModel.TypeGame model, out string message)
        {
            message = null;
            if (string.IsNullOrEmpty(model.NameJanr))
            {
                message = "Type game is empty";
                return(false);
            }
            Models.DBModel.TypeGame typeGameDB = new Models.DBModel.TypeGame
            {
                NameJanr = model.NameJanr
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertTypeGame(typeGameDB);

            if (!result)
            {
                message = "Type game is not added";
            }
            return(true);
        }
Пример #17
0
        public static bool InsertCpu(Models.BLModel.Cpu model, out string message)
        {
            message = null;
            if (string.IsNullOrEmpty(model.Model))
            {
                message = "Cpu is empty";
                return(false);
            }
            Models.DBModel.Cpu cpu = new Models.DBModel.Cpu
            {
                Model = model.Model
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertCpu(cpu);

            if (!result)
            {
                message = "Cpu  is not added";
            }
            return(true);
        }
Пример #18
0
        public static bool InsertVideoCard(Models.BLModel.VideoCard model, out string message)
        {
            message = null;
            if (string.IsNullOrEmpty(model.Model))
            {
                message = "Video Card is empty";
                return(false);
            }
            Models.DBModel.VideoCard video = new Models.DBModel.VideoCard
            {
                Model  = model.Model,
                SizeVC = model.SizeVC
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertVideoCard(video);

            if (!result)
            {
                message = "Video Card  is not added";
            }
            return(true);
        }
Пример #19
0
        public static bool InsertOS(Models.BLModel.OS model, out string message)
        {
            message = null;
            if (string.IsNullOrEmpty(model.Name))
            {
                message = "Operation system is empty";
                return(false);
            }
            Models.DBModel.OS oS = new Models.DBModel.OS
            {
                Name      = model.Name,
                VersionOS = model.VersionOS
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.InsertOs(oS);

            if (!result)
            {
                message = "Operation system  is not added";
            }
            return(true);
        }
Пример #20
0
    public static DataTable FetchAllRecord()
    {
        SqlConnection con = null;
        DataTable     dt  = null;

        try
        {
            con = DBLogic.GetConnection();

            String query = "select * from reg ";

            //create the SqlDataAdapter object
            SqlDataAdapter da = new SqlDataAdapter(query, con);

            //create the object Dataset
            DataSet ds = new DataSet();

            //Call the fill Method and pass the
            //DataSet object
            da.Fill(ds);

            //get the no of tables dataset contains
            dt = ds.Tables[0];
        }
        catch (Exception err)
        {
            //Label1.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
        return(dt);
    }
Пример #21
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = DBLogic.FetchAllRecord();

            con.Open();
            //build a query
            String     query = "delete from reg where userid ='" + txtuserid.Text + "'";
            SqlCommand com   = new SqlCommand(query, con);

            //call the method of command object
            int result = com.ExecuteNonQuery();

            if (result > 0)
            {
                Label2.Text = "Record DELETED successfully";
            }
            else
            {
                Label2.Text = "NO Record FOUND";
            }
        }
        catch (Exception err)
        {
            Label2.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Пример #22
0
        public static bool DeleteTypeGame(Models.BLModel.TypeGame model, out string message)
        {
            message = null;
            if (model.Id == 0)
            {
                message = "Choose record";
                return(false);
            }
            Models.DBModel.TypeGame typeGame = new Models.DBModel.TypeGame
            {
                NameJanr = model.NameJanr,
                Id       = model.Id
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.DeleteTypeGame(typeGame);

            if (!result)
            {
                message = "Delete 0 rows";
                return(false);
            }
            return(true);
        }
Пример #23
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        try
        {
            con = DBLogic.GetConnection();
            con.Open();
            String query = "select * from reg where userid = '" + txtuserid.Text + "' and password = '******'";

            SqlCommand com = new SqlCommand(query, con);

            SqlDataReader dr = com.ExecuteReader();

            if (dr.Read())
            {
                Session["uid"] = txtuserid.Text;
                Response.Redirect("AfterLogin.aspx");
            }
            else
            {
                Label4.Text = "INVALID UID OR PASS";
            }
        }
        catch (Exception err)
        {
            Label4.Text = err.Message;
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Пример #24
0
        public static bool DeleteOs(Models.BLModel.OS model, out string message)
        {
            message = null;
            if (model.Id == 0)
            {
                message = "Choose record";
                return(false);
            }
            Models.DBModel.OS os = new Models.DBModel.OS
            {
                Name = model.Name,
                Id   = model.Id
            };
            DBLogic dBLogic = new DBLogic(connectionString);

            var result = dBLogic.DeleteOs(os);

            if (!result)
            {
                message = "Delete 0 rows";
                return(false);
            }
            return(true);
        }
Пример #25
0
 public void PostInsert([FromBody] RestaurantOwner ro)
 {
     DBLogic.InsertRestaurantOwner(ro);
 }
Пример #26
0
 public RestaurantOwner PostLogin([FromBody] Login loginObject)
 {
     return(DBLogic.GetRestaurantOwner(loginObject));
 }
Пример #27
0
 public void Post([FromBody] DataModell data)
 {
     DBLogic.CreateUser(data.UserId, data.FirstName, data.LastName, data.EmailAddress, data.Age);
 }
Пример #28
0
 public ActionResult <IEnumerable <DataModell> > Get()
 {
     return(DBLogic.LoadUsers());
 }
Пример #29
0
 public RestaurantsUserCombo Grade([FromBody] RestaurantUserCombo restaurantUserCombo)
 {
     return(DBLogic.GradeRestaurant(restaurantUserCombo));
 }
Пример #30
0
 public GradeSpread GetGrade(string restaurantName)
 {
     return(DBLogic.ListOfGradeForRestaurant(restaurantName));
 }