Exemplo n.º 1
0
        public HttpResponseMessage Post(HttpRequestMessage request)///
        {
            var json        = request.Content.ReadAsStringAsync().Result;
            var requestData = Newtonsoft.Json.JsonConvert.DeserializeObject <User>(json);

            using (TaskManagerEntities ent = new TaskManagerEntities())
            {
                var response = new HttpResponseMessage();
                response.StatusCode = HttpStatusCode.BadRequest;
                var user = ent.Users.FirstOrDefault(e => e.email == requestData.email);
                if (user != null)
                {
                    response.Content = new StringContent("Email already exists in the system");
                    return(response);
                }
                else
                {
                    response.StatusCode = HttpStatusCode.OK;
                    response.Content    = new ObjectContent <User>(requestData, new JsonMediaTypeFormatter());
                    ent.Users.Add(requestData);
                    ent.SaveChanges();
                    return(response);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to create new task or update an existing task
        /// </summary>
        /// <param name="taskModel"></param>
        /// <returns></returns>
        public string InsertTask(TaskModel taskModel)
        {
            string result = string.Empty;

            using (TaskManagerEntities entity = new TaskManagerEntities())
            {
                if (taskModel != null)
                {
                    Task addTask = new Task();
                    addTask.Task1 = taskModel.Task;
                    if (taskModel.StartDateString != null)
                    {
                        addTask.Start_Date = Convert.ToDateTime(taskModel.StartDateString);
                    }
                    if (taskModel.EndDateString != null)
                    {
                        addTask.End_Date = Convert.ToDateTime(taskModel.EndDateString);
                    }
                    addTask.Priority            = taskModel.Priority;
                    addTask.Parent_Id           = taskModel.ParentId;
                    addTask.Task_Id             = taskModel.TaskId;
                    addTask.IsActive            = true;
                    result                      = addTask.Task_Id == 0 ? "ADD" : "UPDATE";
                    entity.Entry(addTask).State = addTask.Task_Id == 0 ? System.Data.Entity.EntityState.Added : System.Data.Entity.EntityState.Modified;
                    entity.SaveChanges();
                }
            }
            return(result);
        }
Exemplo n.º 3
0
 //Delete Task by ID
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         using (TaskManagerEntities entities = new TaskManagerEntities())
         {
             var entity = entities.Quotes.FirstOrDefault(q => q.QuoteID == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                    "Task with Id = " + id.ToString() + " not found to delete"));
             }
             else
             {
                 entities.Quotes.Remove(entity);
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Exemplo n.º 4
0
        public string SaveProject(Project projectModel)
        {
            if (projectModel != null)
            {
                Project Project = GetProject(projectModel.ProjectID);
                using (TaskManagerEntities db = new TaskManagerEntities())
                {
                    if (Project == null)
                    {
                        projectModel.Status = true;
                        db.Projects.Add(projectModel);
                    }
                    else
                    {
                        Project.ProjectName     = projectModel.ProjectName;
                        Project.Priority        = projectModel.Priority;
                        Project.EndDate         = projectModel.EndDate;
                        Project.StartDate       = projectModel.StartDate;
                        Project.Status          = projectModel.Status;
                        db.Entry(Project).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
            }

            return(projectModel.ProjectID.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// AddTask
        /// </summary>
        /// <param name="taskModel"></param>
        /// <returns></returns>
        public bool AddTask(TaskModel taskModel)
        {
            TaskManagerEntities entity = new TaskManagerEntities();
            Task addTask = new Task();

            addTask.Task1 = taskModel.Task;
            if (taskModel.StartDateString != null)
            {
                addTask.Start_Date = Convert.ToDateTime(taskModel.StartDateString);
            }
            if (taskModel.EndDateString != null)
            {
                addTask.End_Date = Convert.ToDateTime(taskModel.EndDateString);
            }
            addTask.Priority  = taskModel.Priority;
            addTask.Parent_Id = taskModel.ParentId;
            if (!string.IsNullOrEmpty(taskModel.ParentTask))
            {
                ParentTask pTask = new ParentTask();
                pTask.Parent_Task  = taskModel.ParentTask;
                addTask.ParentTask = pTask;
            }
            entity.Tasks.Add(addTask);
            entity.SaveChanges();
            return(true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Method to end task
 /// </summary>
 /// <param name="taskModel"></param>
 /// <returns></returns>
 public bool UpdateTask(TaskModel taskModel)
 {
     using (TaskManagerEntities entity = new TaskManagerEntities())
     {
         if (taskModel != null && taskModel.TaskId != 0)
         {
             Task endTask = new Task();
             endTask.Task_Id = taskModel.TaskId;
             endTask.Task1   = taskModel.Task;
             if (taskModel.StartDateString != null)
             {
                 endTask.Start_Date = Convert.ToDateTime(taskModel.StartDateString);
             }
             if (taskModel.EndDateString != null)
             {
                 endTask.End_Date = Convert.ToDateTime(taskModel.EndDateString);
             }
             endTask.Priority            = taskModel.Priority;
             endTask.Parent_Id           = taskModel.ParentId;
             endTask.IsActive            = false;
             entity.Entry(endTask).State = System.Data.Entity.EntityState.Modified;
             entity.SaveChanges();
         }
         return(true);
     }
 }
Exemplo n.º 7
0
        //Update Task by ID
        public HttpResponseMessage Put(int id, [FromBody] Quote quote)
        {
            try
            {
                using (TaskManagerEntities entities = new TaskManagerEntities())
                {
                    var entity = entities.Quotes.FirstOrDefault(q => q.QuoteID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           "Task with Id " + id.ToString() + " not found to update"));
                    }
                    else
                    {
                        entity.QuoteType = quote.QuoteType;
                        entity.Contact   = quote.Contact;
                        entity.DueDate   = quote.DueDate;
                        entity.Task      = quote.Task;
                        entity.TaskType  = quote.TaskType;

                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Exemplo n.º 8
0
        public int SaveTask(Task taskdetails)
        {
            try
            {
                if (taskdetails != null)
                {
                    TME.Tasks.Add(taskdetails);
                    return(TME.SaveChanges());
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(0);
        }
 public IHttpActionResult InsertTaskDetail(TaskDetail Taskdata)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         ObjTMEntities.TaskDetails.Add(Taskdata);
         ObjTMEntities.SaveChanges();
     }
     catch (Exception ex)
     {
         throw;
     }
     return(Ok(Taskdata));
 }
Exemplo n.º 10
0
        public int AddTask(TaskBL task)
        {
            tblTask tTask = new tblTask
            {
                Task       = task.Task,
                ParentTask = task.ParentTask,
                Priority   = task.Priority,
                StartDate  = task.StartDate,
                EndDate    = task.EndDate,
                IsActive   = true
            };

            _taskManager.tblTasks.Add(tTask);
            int result = _taskManager.SaveChanges();

            return(result);
        }
Exemplo n.º 11
0
        public void Create(User user)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            // taskmanagerEntities.Configuration.ProxyCreationEnabled = false;
            taskmanagerEntities.Users.Add(user);
            taskmanagerEntities.SaveChanges();
        }
        public void Create(Project project)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            // taskmanagerEntities.Configuration.ProxyCreationEnabled = false;
            taskmanagerEntities.Projects.Add(project);
            taskmanagerEntities.SaveChanges();
        }
Exemplo n.º 13
0
 public void AddTask(Task taskData)
 {
     using (var db = new TaskManagerEntities())
     {
         db.Tasks.Add(taskData);
         db.SaveChanges();
     }
 }
        public void Create(Task task)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            // taskmanagerEntities.Configuration.ProxyCreationEnabled = false;
            taskmanagerEntities.Tasks.Add(task);
            taskmanagerEntities.SaveChanges();
        }
 public string UpdateEndTask(GET_TASK_DETAILS_Result objGET_TASK_DETAILS_Result)
 {
     using (TaskManagerEntities db = new TaskManagerEntities())
     {
         var vUpdateEndTask = db.UPDATE_END_TASK(objGET_TASK_DETAILS_Result.Task_ID, objGET_TASK_DETAILS_Result.End_Date);
         db.SaveChanges();
         return(Convert.ToString(vUpdateEndTask));
     }
 }
        public string InsertTaskDetails(GET_TASK_DETAILS_Result objGET_TASK_DETAILS_Result)
        {
            using (TaskManagerEntities db = new TaskManagerEntities())
            {
                var vInsertTaskDetails = db.INSERT_TASK_DETAILS(objGET_TASK_DETAILS_Result.Task_ID, objGET_TASK_DETAILS_Result.Parent_ID, objGET_TASK_DETAILS_Result.Task, objGET_TASK_DETAILS_Result.Start_Date, objGET_TASK_DETAILS_Result.End_Date, objGET_TASK_DETAILS_Result.Priority);

                db.SaveChanges();
                return(Convert.ToString(vInsertTaskDetails));
            }
        }
Exemplo n.º 17
0
        public void Delete(int UserId)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            var DeletedUsers = taskmanagerEntities.Users.Where(x => x.User_Id == UserId).FirstOrDefault();

            taskmanagerEntities.Entry <User>(DeletedUsers).State = System.Data.Entity.EntityState.Deleted;

            taskmanagerEntities.SaveChanges();
        }
 public void DeleteProject(Project project)
 {
     using (taskManagerEntities = new TaskManagerEntities())
     {
         project.Is_Active = false;
         taskManagerEntities.Projects.Add(project);
         taskManagerEntities.Entry(project).State = System.Data.Entity.EntityState.Modified;
         taskManagerEntities.SaveChanges();
     }
 }
        public void UpdateEditFlag(int TaskId, bool EditFlag)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            var UpdatedTasks = taskmanagerEntities.Tasks.Where(x => x.Task_Id == TaskId).FirstOrDefault();

            UpdatedTasks.Edit_Flag = EditFlag;

            taskmanagerEntities.SaveChanges();
        }
        public void Delete(int ProjectId)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            var DeletedProjects = taskmanagerEntities.Projects.Where(x => x.Project_Id == ProjectId).FirstOrDefault();

            taskmanagerEntities.Entry <Project>(DeletedProjects).State = System.Data.Entity.EntityState.Deleted;

            taskmanagerEntities.SaveChanges();
        }
 public void DeleteUser(User user)
 {
     using (taskManagerEntities = new TaskManagerEntities())
     {
         user.Is_Active = false;
         taskManagerEntities.Users.Add(user);
         taskManagerEntities.Entry(user).State = System.Data.Entity.EntityState.Modified;
         taskManagerEntities.SaveChanges();
     }
 }
 public void DeleteTask(Task task)
 {
     using (taskManagerEntities = new TaskManagerEntities())
     {
         task.Is_Active = false;
         taskManagerEntities.Tasks.Add(task);
         taskManagerEntities.Entry(task).State = System.Data.Entity.EntityState.Modified;
         //taskManagerEntities.Entry(task).State = System.Data.Entity.EntityState.Deleted;
         taskManagerEntities.SaveChanges();
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// DeleteTask
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public bool DeleteTask(int taskId)
        {
            TaskManagerEntities entity = new TaskManagerEntities();
            var taskE = entity.Tasks.Where(x => x.Task_Id == taskId).FirstOrDefault();

            if (taskE != null)
            {
                entity.Tasks.Remove(taskE);
                entity.SaveChanges();
            }
            return(true);
        }
Exemplo n.º 24
0
        public void Update(User user)
        {
            TaskManagerEntities taskmanagerEntities = new TaskManagerEntities();

            var UpdatedTasks = taskmanagerEntities.Users.Where(x => x.User_Id == user.User_Id).FirstOrDefault();

            UpdatedTasks.First_Name   = user.First_Name;
            UpdatedTasks.Last_Name    = user.Last_Name;
            UpdatedTasks.Manager_Flag = user.Manager_Flag;

            taskmanagerEntities.SaveChanges();
        }
Exemplo n.º 25
0
 public HttpResponseMessage Delete(int listId, HttpRequestMessage request)
 {
     using (TaskManagerEntities ent = new TaskManagerEntities())
     {
         var response = new HttpResponseMessage();
         response.StatusCode = HttpStatusCode.OK;
         List <List_Tasks> tasks = ent.List_Tasks.ToList();
         foreach (var t in tasks)
         {
             if (t.list_id == listId)
             {
                 ent.List_Tasks.Remove(t);
                 ent.SaveChanges();
             }
         }
         var list = ent.Lists.FirstOrDefault(e => e.id == listId);
         ent.Lists.Remove(list);
         ent.SaveChanges();
         return(response);
     }
 }
 public HttpResponseMessage Delete(int id)
 {
     using (TaskManagerEntities ent = new TaskManagerEntities())
     {
         var response = new HttpResponseMessage();
         response.StatusCode = HttpStatusCode.OK;
         var obj = ent.List_Tasks.FirstOrDefault(task => task.id == id);
         ent.List_Tasks.Remove(obj);
         ent.SaveChanges();
         return(response);
     }
 }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="taskModel"></param>
        /// <returns></returns>

        public bool SubmitUserDetail(UserModel userModel)
        {
            var isSubmitted = false;

            using (TaskManagerEntities objEntities = new TaskManagerEntities())
            {
                var existingTask  = objEntities.INSERT_USER_DETAILS(userModel.User_ID, userModel.First_Name, userModel.Last_Name, userModel.Employee_ID, userModel.Project_ID, userModel.Task_ID, userModel.Action);
                var updatedRecord = objEntities.SaveChanges();
                isSubmitted = existingTask > 0;
            }

            return(isSubmitted);
        }
Exemplo n.º 28
0
        public void DeleteUser(string employeeId)
        {
            User user = GetUser(employeeId);

            if (user != null)
            {
                using (TaskManagerEntities db = new TaskManagerEntities())
                {
                    db.Users.Remove(user);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 29
0
 public void EndTask(int taskId)
 {
     using (var taskManager = new TaskManagerEntities())
     {
         var task = taskManager.tblTasks.Where(t => t.TaskID == taskId).FirstOrDefault();
         if (task != null)
         {
             task.EndDate  = DateTime.Now;
             task.IsActive = false;
             taskManager.SaveChanges();
         }
     }
 }
Exemplo n.º 30
0
        public void DeleteProject(int projectId)
        {
            Project Project = GetProject(projectId);

            if (Project != null)
            {
                using (TaskManagerEntities db = new TaskManagerEntities())
                {
                    db.Projects.Remove(Project);
                    db.SaveChanges();
                }
            }
        }