Exemplo n.º 1
0
 public ActionResult Create(Tbl_Collection model)
 {
     using (var Db = new ProjectWebEntities())
     {
         try
         {
             model.IsHome = true;
             // create new
             if (model.Id == 0)
             {
                 Db.Tbl_Collection.Add(model);
                 Db.SaveChanges();
                 Db.pr_LogSystem_save("Thêm mới dữ liệu(" + model.Name + ")", "Thêm mới", "Cam kết", User.Identity.Name);
             }
             else // update current
             {
                 Db.Entry(model).State = EntityState.Modified;
                 Db.SaveChanges();
                 Db.pr_LogSystem_save("Cập nhật dữ liệu(" + model.Name + ")", "Cập nhật", "Cam kết", User.Identity.Name);
             }
             //Xóa cache
             CacheHelper.ClearAllOutputCache();
         }
         catch (Exception ex)
         {
             logger.Error("An Error Happened! ", ex);
         }
         return(RedirectToAction("Index", "Commit"));
     }
 }
        public JsonResult SetLogin(Tbl_Collection OP, bool Remember)
        {
            if (Session["TryLoginCol"] != null && Convert.ToInt32(Session["TryLoginCol"]) >= 5)
            {
                try
                {
                    DateTime trydate = Convert.ToDateTime(Session["TryLoginColDate"]);
                    TimeSpan span    = DateTime.Now.Subtract(trydate);
                    if (span.TotalMinutes < 10)
                    {
                        return(Json(new { result = false, message = "بیش از حد مجاز تلاش کرده اید، 10 دقیقه دیگر سعی کنید" }));
                    }
                    else
                    {
                        Session.Add("TryLoginCol", 0);
                        SetLogin(OP, Remember);
                    }
                }
                catch (Exception)
                {
                    Session.Add("TryLoginColDate", DateTime.Now);
                    return(Json(new { result = false, message = "بیش از حد مجاز تلاش کرده اید، 10 دقیقه دیگر سعی کنید" }));
                }
            }
            Hash hh    = new Hash();
            var  pass  = hh.Encrypt(OP.password);
            var  check = db.Tbl_Collection.Where(c => c.username == OP.username && c.password == pass).FirstOrDefault();

            if (check != null)
            {
                Session.Add("TryLoginCol", 0);
                if (collection.AddSession(check))
                {
                    if (check.active == false)
                    {
                        return(Json(new { result = false, message = "دسترسی شما غیرفعال شده است با مدیریت تماس بگیرید" }));
                    }

                    return(Json(new { result = true }));
                }
                else
                {
                    return(Json(new { result = false, message = "خطای سیستمی رخ داده است" }));
                }
            }
            else
            {
                if (Session["TryLoginCol"] != null)
                {
                    Session.Add("TryLoginCol", (int)Session["TryLoginCol"] + 1);
                }
                else
                {
                    Session.Add("TryLoginCol", 1);
                }
                Session.Add("TryLoginColDate", DateTime.Now);
                return(Json(new { result = false, message = "نام کاربری یا رمزعبور اشتباه است" }));
            }
        }
Exemplo n.º 3
0
        public void ChangeIsDisable(Tbl_Collection input)
        {
            var Db = new ProjectWebEntities();

            try
            {
                var model = Db.Tbl_Collection.Find(input.Id);
                model.IsDisable       = input.IsDisable;
                Db.Entry(model).State = EntityState.Modified;
                Db.SaveChanges();
                Db.pr_LogSystem_save("Cập nhật trạng thái sử dụng(" + model.Name + ")", "Cập nhật", "Cam kết", User.Identity.Name);
                //Xóa cache
                CacheHelper.ClearAllOutputCache();
            }
            catch (Exception ex)
            {
                logger.Error("An Error Happened! ", ex);
            }
        }
Exemplo n.º 4
0
        public ActionResult Collection_Destroy([DataSourceRequest] DataSourceRequest request, Tbl_Collection model)
        {
            using (var Db = new ProjectWebEntities())
            {
                try
                {
                    var m = Db.Tbl_Collection.Find(model.Id);
                    Db.Tbl_Collection.Remove(m);

                    Db.SaveChanges();
                    Db.pr_LogSystem_save("Xóa dữ liệu(" + model.Name + ")", "Xóa", "Cam kết", User.Identity.Name);
                    //Xóa cache
                    CacheHelper.ClearAllOutputCache();
                }
                catch (Exception ex)
                {
                    logger.Error("An Error Happened! ", ex);
                }
                return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
            }
        }