예제 #1
0
        public ActionResult Create([Bind(Include = "LogID,MethodName,ExMessage,Message,CreatedDate,CreatedUser")] Logs logs)
        {
            if (ModelState.IsValid)
            {
                db.Logs.Add(logs);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(logs));
        }
예제 #2
0
        public ActionResult TaskDelete(Tasks task)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                Tasks taskdelete = null;

                using (var db = new CepNotEntities())
                {
                    taskdelete             = db.Tasks.Where(d => d.TaskID == task.TaskID).First();
                    taskdelete.Title       = task.Title;
                    taskdelete.Description = task.Description;
                    taskdelete.Date        = task.Date;
                    taskdelete.Type        = task.Type;
                    taskdelete.CreatedDate = task.CreatedDate;
                    taskdelete.SId         = task.SId;
                    taskdelete.AId         = task.AId;
                    taskdelete.IsActive    = task.IsActive;
                    taskdelete.IsDeleted   = true;

                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
        }
예제 #3
0
        public ActionResult UserDelete(Users user)
        {
            if (Session["UserId"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                Users userdelete = null;

                using (var db = new CepNotEntities())
                {
                    userdelete           = db.Users.Where(d => d.UserID == user.UserID).First();
                    userdelete.Name      = user.Name;
                    userdelete.Age       = user.Age;
                    userdelete.Gender    = user.Gender;
                    userdelete.Mail      = user.Mail;
                    userdelete.Password  = user.Password;
                    userdelete.Role      = user.Role;
                    userdelete.IsDeleted = true;

                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
        }
예제 #4
0
        public JsonResult TaskManSave(TaskManagerDetail taskManagerDetail)
        {
            ReturnValue ret     = new ReturnValue();
            Tasks       taskadd = new Tasks();

            if (Shared.CheckSession() == false)
            {
                ret.requiredLogin = true;
                ret.message       = "Lütfen giriş yapınız.";
                ret.success       = false;
                return(Json(ret));
            }

            try
            {
                using (var db = new CepNotEntities())
                {
                    if (taskManagerDetail.TaskID != 0)
                    {
                        taskadd = db.Tasks.Where(x => x.TaskID == taskManagerDetail.TaskID).FirstOrDefault();
                    }


                    taskadd.AId         = taskManagerDetail.AId;
                    taskadd.SId         = taskManagerDetail.SId;
                    taskadd.Title       = taskManagerDetail.Title;
                    taskadd.Description = taskManagerDetail.Description;
                    taskadd.Date        = taskManagerDetail.Date;
                    taskadd.Type        = taskManagerDetail.Type;
                    taskadd.CreatedDate = taskManagerDetail.CreatedDate;
                    taskadd.CreatedUser = taskManagerDetail.CreatedUser;
                    taskadd.IsActive    = taskManagerDetail.IsActive;
                    taskadd.IsDeleted   = taskManagerDetail.IsDeleted;


                    if (taskManagerDetail.TaskID == 0)
                    {
                        db.Tasks.Add(taskadd);
                    }

                    db.SaveChanges();
                    ret.retObject = taskManagerDetail;
                }
                ret.message = "Başarıyla kaydedildi.";
                ret.success = true;
            }
            catch (Exception ex)
            {
                ex.AddToDBLog("HomeController.AddTaskMan");
                ret.success = false;
                ret.message = ex.Message;
            }

            return(Json(ret));
        }
예제 #5
0
        //Veritabanına log ekler.
        public static void AddToDBLog(this Exception exc, string MethodName, string Message = "")
        {
            Logs logum = new Logs();

            using (var db = new CepNotEntities())
            {
                logum.CreatedDate = DateTime.Now;
                logum.CreatedUser = Convert.ToInt32(HttpContext.Current.Session["UserId"]);
                logum.ExMessage   = exc.ToString();
                logum.MethodName  = MethodName;
                logum.Message     = Message;

                db.Logs.Add(logum);
                db.SaveChanges();
            }
        }
예제 #6
0
        public ActionResult UserUpdateO(Users user)
        {
            Users userupdate = null;

            using (var db = new CepNotEntities())
            {
                userupdate          = db.Users.Where(d => d.UserID == user.UserID).First();
                userupdate.Name     = user.Name;
                userupdate.Age      = user.Age;
                userupdate.Gender   = user.Gender;
                userupdate.Mail     = user.Mail;
                userupdate.Password = user.Password;

                db.SaveChanges();
            }
            return(RedirectToAction("UserProfileO", new { id = user.UserID }));
        }
예제 #7
0
        public ActionResult UserAdder(Users user)
        {
            Users useradd = new Users();

            using (var db = new CepNotEntities())
            {
                useradd.Name      = user.Name;
                useradd.Age       = null;
                useradd.Gender    = user.Gender;
                useradd.Mail      = user.Mail;
                useradd.Password  = user.Name;
                useradd.IsDeleted = false;
                useradd.Role      = user.Role;

                db.Users.Add(useradd);
                db.SaveChanges();
            }
            return(RedirectToAction("TaskManager", "Home"));
        }
예제 #8
0
        public ActionResult TaskUpdate(Tasks task)
        {
            Tasks taskupdate = null;

            using (var db = new CepNotEntities())
            {
                taskupdate             = db.Tasks.Where(d => d.TaskID == task.TaskID).First();
                taskupdate.Title       = task.Title;
                taskupdate.Description = task.Description;
                taskupdate.Date        = task.Date;
                taskupdate.Type        = task.Type;
                taskupdate.CreatedDate = task.CreatedDate;
                taskupdate.IsActive    = task.IsActive;
                taskupdate.IsDeleted   = task.IsDeleted;
                taskupdate.SId         = task.SId;
                taskupdate.AId         = task.AId;

                db.SaveChanges();
            }
            return(RedirectToAction("TaskDetail", new { id = task.TaskID }));
        }
예제 #9
0
        public ActionResult TaskAdder(Tasks task)
        {
            Tasks taskadd = new Tasks();

            using (var db = new CepNotEntities())
            {
                taskadd.Title       = task.Title;
                taskadd.Description = task.Description;
                taskadd.Date        = task.Date;
                taskadd.Type        = task.Type;
                taskadd.CreatedDate = task.CreatedDate;
                taskadd.IsActive    = true;
                taskadd.IsDeleted   = false;
                taskadd.SId         = task.SId;
                taskadd.AId         = task.AId;

                db.Tasks.Add(taskadd);
                db.SaveChanges();
            }
            return(RedirectToAction("Tasks", "Home"));
        }