Example #1
0
 public List <DATA.Domains.Employee> GetEmployees()
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         return(context.Employee.Include("Department").Where(x => x.IsActive).ToList());
     }
 }
Example #2
0
 public List <DATA.Domains.ProductType> GetProductType()
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         return(context.ProductType.ToList());
     }
 }
Example #3
0
 public List <Department> GetDepartments()
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         return(context.Department.ToList());
     }
 }
Example #4
0
 public void AddProduct(DATA.Domains.Product product)
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         context.Product.Add(product);
         context.SaveChanges();
     }
 }
Example #5
0
 public void AddEmployee(DATA.Domains.Employee employee)
 {
     using (UbDbcontext context = new UbDbcontext())
     {
         context.Employee.Add(employee);
         context.SaveChanges();
     }
 }
Example #6
0
        public DATA.Domains.Employee EditEmployee(int id)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var employee = context.Employee.Include("Department").Where(x => x.Id == id && !x.IsDeleted).FirstOrDefault();

                return(employee);
            }
        }
Example #7
0
        //public DATA.Domains.Attendance GetAttendanceByEmployeeId(int employeeId)
        //{
        //    using (UbDbcontext context = new UbDbcontext())
        //    {
        //        var attendence = context.Attendance.Where(x => x.EmployeeId == employeeId).FirstOrDefault();

        //        return attendence;
        //    }
        //}

        public List <DATA.Domains.Attendance> GetFullAttendance()
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var attendence = context.Attendance.ToList();

                return(attendence);
            }
        }
Example #8
0
        public void DeleteEmployee(int id)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var employeeToDelete = context.Employee.Where(x => x.Id == id).FirstOrDefault();
                employeeToDelete.IsDeleted = true;
                employeeToDelete.IsActive  = false;

                context.SaveChanges();
            }
        }
Example #9
0
        public void UpdateEmployee(DATA.Domains.Employee employee)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                var employeeToUpdate = context.Employee.Where(x => x.Id == employee.Id).FirstOrDefault();

                employeeToUpdate.FirstName    = employee.FirstName;
                employeeToUpdate.LastName     = employee.LastName;
                employeeToUpdate.CNIC         = employee.CNIC;
                employeeToUpdate.CellNo       = employee.CellNo;
                employeeToUpdate.DepartmentId = employee.DepartmentId;

                context.SaveChanges();
            }
        }
Example #10
0
        public void AddAttendace(DATA.Domains.Attendance attendance)
        {
            using (UbDbcontext context = new UbDbcontext())
            {
                try
                {
                    var already = context.Attendance.Where(x => x.EmployeeName == attendance.EmployeeName && x.Date == attendance.Date).ToList();


                    if (!already.Any())
                    {
                        context.Attendance.Add(attendance);

                        context.SaveChanges();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }