Esempio n. 1
0
 /// <summary>
 /// Remove Task from the database
 /// </summary>
 /// <param name="TaskId">TaskId</param>
 /// <returns>Status of the Operation</returns>
 public string RemoveTask(int TaskId)
 {
     try
     {
         using (CapsuleEntities PE = new CapsuleEntities())
         {
             PE.Configuration.ProxyCreationEnabled = false;
             TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault();
             if (I == null)
             {
                 return("Task with Id " + TaskId + " Not found");
             }
             else
             {
                 PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                 PE.SaveChanges();
                 return("Success");
             }
         }
     }
     catch (Exception ex)
     {
         return("Failed : " + ex.Message);
     }
 }
Esempio n. 2
0
        public void UpdateTask(Task task)
        {
            db.Entry(task).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }

            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Remove Project from the database
        /// </summary>
        /// <param name="ProjectId">ProjectId</param>
        /// <returns>Status of the Operation</returns>

        public Project RemoveProject(int ProjectId)
        {
            try
            {
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    Project I = PE.Projects.Where(x => x.ProjectId == ProjectId).FirstOrDefault();

                    PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                    PE.SaveChanges();
                    return(I);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Remove Task from the database
        /// </summary>
        /// <param name="TaskId">TaskId</param>
        /// <returns>Status of the Operation</returns>
        public TaskInformation RemoveTask(int TaskId)
        {
            try
            {
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    TaskInformation I = PE.TaskInformations.Where(x => x.TaskId == TaskId).FirstOrDefault();

                    PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                    PE.SaveChanges();
                    return(I);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Remove User from the database
        /// </summary>
        /// <param name="UserId">UserId</param>
        /// <returns>Status of the Operation</returns>
        public User RemoveUser(int UserId)
        {
            try
            {
                User I = null;
                using (CapsuleEntities PE = new CapsuleEntities())
                {
                    PE.Configuration.ProxyCreationEnabled = false;
                    I = PE.Users.Where(x => x.UserId == UserId).FirstOrDefault();

                    PE.Entry(I).State = System.Data.Entity.EntityState.Deleted;
                    PE.SaveChanges();
                }
                return(I);
            }

            catch (Exception)
            {
                throw;
            }
        }