Ejemplo n.º 1
0
        public ActionResult AddProduct(ProductTable PD)
        {
            ProductDatabaseEntities db = new ProductDatabaseEntities();

            ProductTable pt = new ProductTable();

            pt.ProductName = PD.ProductName;
            pt.Price       = PD.Price;
            pt.Brand       = PD.Brand;
            pt.Type        = PD.Type;
            pt.Details     = PD.Details;
            //pt.ImageData = PD.ImageData;


            //byte[] data = new byte[pt.File.ContentLength];
            byte[] data = new byte[PD.File.ContentLength];
            PD.File.InputStream.Read(data, 0, PD.File.ContentLength);
            pt.ImageData = data;
            using (ProductDatabaseEntities dc = new ProductDatabaseEntities())
            {
                dc.ProductTables.Add(pt);
                dc.SaveChanges();
                @ViewBag.Success = "Seccessfully Added!";
            }


            return(RedirectToAction("AddProduct"));
        }
Ejemplo n.º 2
0
 public ActionResult Signup(user model)
 {
     using (var context = new ProductDatabaseEntities())
     {
         context.users.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("login"));
 }
Ejemplo n.º 3
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            List <ProductTable> all = new List <ProductTable>();

            using (ProductDatabaseEntities dc = new ProductDatabaseEntities())

                all = dc.ProductTables.ToList();

            return(View(all));
        }
Ejemplo n.º 4
0
        public ActionResult cat(string name)
        {
            List <ProductTable> all2 = new List <ProductTable>();

            using (ProductDatabaseEntities dc = new ProductDatabaseEntities())

                all2 = dc.ProductTables.Where(x => x.Type == name).ToList();
            //ViewBag.P = P;


            return(View(all2));
        }
Ejemplo n.º 5
0
 public ActionResult Login(Models.Membership model)
 {
     using (var context = new ProductDatabaseEntities())
     {
         bool isvalid = context.users.Any(x => x.username == model.username && x.password == model.password);
         if (isvalid)
         {
             FormsAuthentication.SetAuthCookie(model.username, false);
             return(RedirectToAction("Index", "ProductListDatas"));
         }
         ModelState.AddModelError("", "Invalid Username or Password");
         return(View());
     }
 }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            using (var db = new ProductDatabaseEntities())
            {
                if (db != null)
                {
                    var empl = db.ProductTables.ToList();
                    var user = db.UserTables.ToList();
                    if (user != null)
                    {
                        if (!string.IsNullOrEmpty(user.Where(u => u.Name == context.UserName && u.Password == context.Password).FirstOrDefault().Name))
                        {
                            identity.AddClaim(new Claim("Age", "16"));

                            var props = new AuthenticationProperties(new Dictionary <string, string>
                            {
                                {
                                    "userdisplayname", context.UserName
                                },
                                {
                                    "role", "admin"
                                }
                            });

                            var ticket = new AuthenticationTicket(identity, props);
                            context.Validated(ticket);
                        }
                        else
                        {
                            context.SetError("invalid_grant", "Provided username and password is incorrect");
                            context.Rejected();
                        }
                    }
                }
                else
                {
                    context.SetError("invalid_grant", "Provided username and password is incorrect");
                    context.Rejected();
                }
                return;
            }
        }