Пример #1
0
        //task text
        #region To add Task Detail in Database
        public int AddTask(TaskEntity _task)
        {
            int         retVal = 0;
            GenericTask Task   = new GenericTask();

            using (var db = new DbContext(CONNECTION_NAME))
            {
                try
                {
                    Task = db.Set <GenericTask>().Where(s => s.tsk_TaskID == _task.tsk_TaskID).FirstOrDefault <GenericTask>();
                    if (Task != null)
                    {
                        return(retVal);
                    }
                    db.Set <GenericTask>().Add(new GenericTask
                    {
                        tsk_TaskName        = _task.tsk_TaskName,
                        tsk_TaskDescription = _task.tsk_TaskDescription,
                        tsk_ActiveStatus    = _task.tsk_ActiveStatus,
                        tsk_Version         = _task.tsk_Version,
                        tsk_CreatedBy       = _task.tsk_CreatedBy,
                        tsk_CreatedDate     = System.DateTime.Now,
                        tsk_isDeleted       = false
                    });
                    db.SaveChanges();
                    retVal = 1;
                }
                catch (Exception ex)
                {
                    retVal = -1;
                }
            }
            return(retVal);
        }
Пример #2
0
        public int DeleteTaskDetail(int ID)
        {
            int         retVal   = 0;
            GenericTask _taskDtl = null;

            using (var db = new DbContext(CONNECTION_NAME))
            {
                try
                {
                    _taskDtl = db.Set <GenericTask>().Where(s => s.tsk_TaskID == ID).FirstOrDefault <GenericTask>();
                    if (_taskDtl == null)
                    {
                        return(retVal);
                    }
                    _taskDtl.tsk_isDeleted   = true;
                    db.Entry(_taskDtl).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retVal = 1;
                }
                catch (Exception ex)
                {
                    retVal = -1;
                }
            }
            return(retVal);
        }
Пример #3
0
        public int UpdateTaskDetail(TaskEntity Task)
        {
            GenericTask _taskDtl = null;
            //History_tasks _taskHistory = new History_tasks();

            int retVal = 0;

            using (var db = new DbContext(CONNECTION_NAME))
            {
                try
                {
                    _taskDtl = db.Set <GenericTask>().Where(s => s.tsk_TaskID == Task.tsk_TaskID).FirstOrDefault <GenericTask>();

                    if (_taskDtl == null)
                    {
                        return(retVal);
                    }

                    #region Saving History into History_task Table

                    ////check for  _taskDtl.tsk_ModifiedDate as created date to history table
                    //DateTime dtAccCreatedDate = _taskDtl.tsk_ModifiedDate ?? DateTime.Now;

                    //db.Set<History_tasks>().Add(new History_tasks
                    //{
                    //    History_tsk_taskID = _taskDtl.tsk_taskID,
                    //    History_tsk_TaskName = _taskDtl.tsk_TaskName,
                    //    History_tsk_TaskDescription = _taskDtl.tsk_TaskDescription,
                    //    History_tsk_ActiveStatus = _taskDtl.tsk_ActiveStatus,
                    //    History_tsk_Version = _taskDtl.tsk_Version,
                    //    History_tsk_CreatedDate = dtAccCreatedDate,
                    //    History_tsk_CreatedBy = _taskDtl.tsk_CreatedBy,
                    //    History_tsk_ModifiedDate = _taskDtl.tsk_ModifiedDate,
                    //    History_tsk_ModifiedBy = _taskDtl.tsk_ModifiedBy,
                    //    History_tsk_isDeleted = _taskDtl.tsk_isDeleted
                    //});
                    #endregion

                    #region Saving Task info Table

                    _taskDtl.tsk_TaskName        = Task.tsk_TaskName;
                    _taskDtl.tsk_TaskDescription = Task.tsk_TaskDescription;
                    _taskDtl.tsk_ActiveStatus    = Task.tsk_ActiveStatus;
                    _taskDtl.tsk_Version         = Task.tsk_Version;
                    _taskDtl.tsk_ModifiedDate    = System.DateTime.Now;
                    _taskDtl.tsk_ModifiedBy      = Task.tsk_ModifiedBy;
                    _taskDtl.tsk_isDeleted       = Task.tsk_isDeleted;
                    #endregion
                    db.Entry(_taskDtl).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    retVal = 1;
                }
                catch (Exception ex)
                {
                    retVal = -1;
                }
                return(retVal);
            }
        }