예제 #1
0
        /// <summary>
        /// Adds the specified task.
        /// </summary>
        /// <param name="task">The task.</param>
        /// <returns></returns>
        public tbl_Task Add(tbl_Task task)
        {
            task.ID = Guid.NewGuid();
            _dataContext.tbl_Task.AddObject(task);
            _dataContext.SaveChanges();

            return(task);
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_Task tbl_task = db.tbl_Task.Find(id);

            db.tbl_Task.Remove(tbl_task);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult Delete(int id = 0)
        {
            tbl_Task tbl_task = db.tbl_Task.Find(id);

            if (tbl_task == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_task));
        }
예제 #4
0
 public ActionResult Edit(tbl_Task tbl_task)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_task).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_task));
 }
예제 #5
0
        public TaskVM GetTaskInfoById(int id)
        {
            TaskVM dto = new TaskVM();

            tbl_Task objTask = entDB.tbl_Task.Find(id);

            dto.Id       = objTask.Id;
            dto.TaskName = objTask.TaskName;

            return(dto);
        }
예제 #6
0
 // PUT: api/Tasks/5
 public bool Put(tbl_Task task)
 {
     try
     {
         return(unitOfWork.TaskManager.UpdateEntity(task));
     }
     catch
     {
         return(false);
     }
 }
예제 #7
0
        public ActionResult Create(tbl_Task tbl_task)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Task.Add(tbl_task);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_task));
        }
예제 #8
0
        // POST: api/Tasks
        public bool Post(tbl_Task task)
        {
            var id = unitOfWork.TaskManager.MaxId(task);

            for (int i = 0; true; i++)
            {
                if (unitOfWork.TaskManager.GetByID(id) == null)
                {
                    task.id = id;
                    return(unitOfWork.TaskManager.AddEntity(task));
                }
                id++;
            }
        }
예제 #9
0
        public bool DeleteTaskInfo(int id)
        {
            bool isDeleted = false;

            try
            {
                tbl_Task objTask = entDB.tbl_Task.Find(id);
                entDB.tbl_Task.Remove(objTask);
                entDB.SaveChanges();
                isDeleted = true;
            }
            catch
            {
                return(false);
            }

            return(isDeleted);
        }
예제 #10
0
        public bool UpdateTaskInfo(TaskVM dtoTask)
        {
            bool isSaved = false;

            try
            {
                tbl_Task objTask = new tbl_Task();
                objTask.Id       = dtoTask.Id;
                objTask.TaskName = dtoTask.TaskName;

                entDB.Entry(objTask).State = EntityState.Modified;
                entDB.SaveChanges();
                isSaved = true;
            }
            catch
            {
                return(false);
            }

            return(isSaved);
        }
예제 #11
0
        public bool CreateTaskInfo(TaskVM dtoTask)
        {
            bool isSaved = false;

            try
            {
                tbl_Task objTask = new tbl_Task();

                objTask.TaskName = dtoTask.TaskName;


                entDB.tbl_Task.Add(objTask);
                entDB.SaveChanges();
                isSaved = true;
            }
            catch
            {
                return(false);
            }

            return(isSaved);
        }
예제 #12
0
 /// <summary>
 /// Updates the specified task.
 /// </summary>
 /// <param name="task">The task.</param>
 public void Update(tbl_Task task)
 {
     _dataContext.SaveChanges();
 }
예제 #13
0
 // PUT: api/Tasks/5
 public bool Put(tbl_Task task)
 {
     return(unitOfWork.TaskManager.UpdateEntity(task));
 }