Example #1
0
 public static MyECommerceEntities GetConnection()
 {
     if (db == null)
     {
         db = new MyECommerceEntities();
     }
     return(db);
 }
Example #2
0
 public ActionResult SignIn(Member member)
 {
     using (MyECommerceEntities db = new MyECommerceEntities())
     {
         var userDetails = db.Members.FirstOrDefault(t => t.Email == member.Email && t.Password == member.Password);
         if (userDetails == null)
         {
             return(View("SignIn", member));
         }
         else
         {
             Session["UserID"] = userDetails;
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
 public ActionResult AdminLogin(Member member)
 {
     using (MyECommerceEntities db = new MyECommerceEntities())
     {
         var userDetails = db.Members.FirstOrDefault(t => t.Email == member.Email && t.Password == member.Password && t.RoleId == 1);
         if (userDetails == null)
         {
             ViewBag.Mesaj = "E-mail veya sifre yanlis";
             return(RedirectToAction("AdminLogin", "AdminLogin"));
         }
         else
         {
             Session["UserID"] = userDetails;
             return(RedirectToAction("AdminHome", "AdminHome"));
         }
     }
 }
        public Result <int> GetResult(MyECommerceEntities db)
        {
            Result <int> result            = new Result <int>();
            int          transactionResult = db.SaveChanges();

            if (transactionResult > 0)
            {
                result.UserMassage   = "Operation Successful.";
                result.IsSucceeded   = true;
                result.ProcessResult = transactionResult;
            }
            else
            {
                result.UserMassage   = "Operation Failed!";
                result.IsSucceeded   = false;
                result.ProcessResult = transactionResult;
            }
            return(result);
        }
Example #5
0
        public ActionResult Login(LoginVM model)
        {
            if (ModelState.IsValid)
            {
                using (MyECommerceEntities context = new MyECommerceEntities())
                {
                    var user = context.Members.FirstOrDefault(x => x.Email == model.Email && x.Password == model.Password);
                    if (user != null)
                    {
                        //FormsAuthentication.SetAuthCookie(user.UserName, true);
                        FormsAuthentication.SetAuthCookie(user.UserId.ToString(), true);
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            ViewBag.Message = "Kullanici adi veya Parola Yanlış";
            return(View());
        }
Example #6
0
        public Result <int> GetResult(MyECommerceEntities db)
        {
            Result <int> result = new Result <int>();
            int          sonuc  = db.SaveChanges();

            if (sonuc > 0)
            {
                result.UserMessage   = "Basarili";
                result.IsSuccessed   = true;
                result.ProcessResult = sonuc;
            }
            else
            {
                result.UserMessage   = "Basarisiz";
                result.IsSuccessed   = false;
                result.ProcessResult = sonuc;
            }
            return(result);
        }