Exemple #1
0
 public Boolean UpdateEmployee(Employee emp)
 {
     try
     {
         _context.Entry(emp).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public Boolean UpdatePage(PageDetail page)
 {
     try
     {
         _context.Entry(page).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #3
0
 public Boolean UpadateType(PageType type)
 {
     try
     { var test = _context.PageTypes.Where(c => c.TypeId == type.TypeId).Select(c => new { c.IsActive }).FirstOrDefault();
       type.IsActive = test.IsActive;
       _context.Entry(type).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
       _context.SaveChanges();
       return(true); }
     catch
     {
         return(false);
     }
 }
Exemple #4
0
        /// <summary>
        /// return boolean value after update employee
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>boolean</returns>
        public int UpdateEmployee(Employee employee)
        {
            try
            {   //get employees' positionid and profile pic name
                var employeedetail = _context.Employees.Where(c => c.EmpEmail == employee.EmpEmail).Select(c => new { c.EmpProfilePicture, c.PositionPId, c.RegisterCode, c.Id, c.EmpPassword }).FirstOrDefault();
                if (employee.EmpPassword != employeedetail.EmpPassword)
                {
                    return(2);
                }
                if (employee.PositionPId == null || employee.PositionPId == "")
                {
                    employee.PositionPId = employeedetail.PositionPId;
                }

                employee.RegisterCode = employeedetail.RegisterCode;
                //if there is not new employee picture leave the previous profile pic name
                if (employee.EmpProfilePicture == null || employee.EmpProfilePicture == "")
                {
                    employee.EmpProfilePicture = employeedetail.EmpProfilePicture;
                }
                employee.Id = employeedetail.Id;
                _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();
                return(1);
            }
            catch
            {
                return(0);
            }
        }
Exemple #5
0
 /// <summary>
 /// update project details
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 public Boolean UpdateProject(Project project)
 {
     try
     {
         project.IsActive = true;
         _context.Entry(project).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #6
0
        /// <summary>
        /// For Insert or Update the Employee based on Employee Id(incliding the EmployeeLanguages Maps and Files)
        /// </summary>
        /// <param name="employee">Employee</param>
        /// <param name="employeeLanguagesList">employeeLanguages Maps List</param>
        /// <param name="files">Files Uploaded</param>
        /// <returns>True is for successfully transaction done , flase is not</returns>
        public bool InsertUpdateEmployee(Employee employee)
        {
            var flag = false;

            using (context)
            {
                //Begin the Transaction for Mutiple Table Data Isertion
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (employee.EmpId == 0)
                        {
                            employee = context.Employee.Add(employee);
                            context.SaveChanges();
                        }
                        else
                        {
                            //Insert Employee Landuage Mappings
                            InsertEmployeeLanguages(employee.EmpId, employee.EmployeeLanguages, context);


                            //Insert New Files
                            FileDataManager.InsertFiles(employee.Files, employee.EmpId, context);

                            //Update Employee
                            context.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                            context.SaveChanges();
                        }

                        dbContextTransaction.Commit();
                        flag = true;
                    }
                    catch
                    {
                        dbContextTransaction.Rollback();
                        flag = false;

                        //Here we trace the Exception in DB
                    }
                }
            }
            return(flag);
        }
Exemple #7
0
        public Boolean ToAdmin(string email)
        {
            try
            {
                User user = new User();
                user = _context.Users
                       .Where(c => c.Email == email)
                       .Where(c => c.Active == true)
                       .FirstOrDefault();
                user.Role = "admin";

                _context.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
 public Boolean UpdateCricketTeam(CricketTeam team)
 {
     try
     {
         _context.Entry(team).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// Task Update
 /// </summary>
 /// <param name="task"></param>
 /// <returns></returns>
 public Boolean UpdateTask(Task task)
 {
     try
     {
         _context.Entry(task).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #10
0
 /// <summary>
 /// update department
 /// </summary>
 /// <param name="dprt"></param>
 /// <returns></returns>
 public Boolean UpdateDepartment(Department dprt)
 {
     try
     {
         _context.Entry(dprt).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 /// <summary>
 /// update position in table
 /// </summary>
 /// <param name="role"></param>
 /// <returns> boolean</returns>
 public Boolean UpdatePosition(Position role)
 {
     try
     {
         _context.Entry(role).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }