Exemplo n.º 1
0
        public HttpResponseMessage AddNewOrEditBuiding(BuidingDto dto)
        {
            if (dto == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    ErrorMessage = "Parammeter null",
                    ResponseMessage = ""
                }));
            }

            if (dto.Id != Guid.Empty)
            {
                var buiding = GetBuidingById(dto.Id);
                if (buiding != null)
                {
                    buiding.BuidingName = dto.BuidingName;
                    buiding.StartDate   = dto.StartDate;
                    buiding.EndDate     = dto.EndDate;
                    buiding.Address     = dto.Address;
                    buiding.UpdateDate  = DateTime.Now;
                }
                else
                {
                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Can't Find Department Width Id" + dto.Id
                    }));
                }
            }
            else
            {
                var buiding = new Buiding()
                {
                    BuidingName = dto.BuidingName,
                    StartDate   = dto.StartDate,
                    EndDate     = dto.EndDate,
                    Address     = dto.Address,
                };
                _context.Buidings.Add(buiding);
            }
            _context.SaveChanges();
            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Add Buiding success"
            }));
        }
Exemplo n.º 2
0
        public HttpResponseMessage AddNewOrEditJoinBuiding(JoinBuidingDto dto)
        {
            if (dto == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    ErrorMessage = "Parammeter null",
                    ResponseMessage = ""
                }));
            }

            if (dto.Id != Guid.Empty)
            {
                var joinBuiding = GetJoinBuidingById(dto.Id);
                if (joinBuiding != null)
                {
                    joinBuiding.WorkDate   = dto.WorkDate;
                    joinBuiding.EmployeeId = dto.EmployeeId;
                    joinBuiding.BuidingId  = dto.EmployeeId;
                }
                else
                {
                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Can't Find JoinBuiding Width Id" + dto.Id
                    }));
                }
            }
            else
            {
                var joinBuiding = new JoinBuiding()
                {
                    WorkDate   = dto.WorkDate,
                    EmployeeId = dto.EmployeeId,
                    BuidingId  = dto.EmployeeId
                };
                _context.JoinBuidings.Add(joinBuiding);
            }
            _context.SaveChanges();
            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Add JoinBuiding success"
            }));
        }
Exemplo n.º 3
0
        public HttpResponseMessage AddNewOrEditDepartment(DepartmentDto dto)
        {
            if (dto == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    ErrorMessage = "Parammeter null",
                    ResponseMessage = ""
                }));
            }

            if (dto.Id != Guid.Empty)
            {
                var department = GetDepartmentById(dto.Id);
                if (department != null)
                {
                    department.DepartmentName = dto.DepartmentName;
                    department.ManagerPerson  = dto.ManagerPerson;
                    department.UpdateDate     = DateTime.Now;
                }
                else
                {
                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Can't Find Department Width Id" + dto.Id
                    }));
                }
            }
            else
            {
                var department = new Department()
                {
                    DepartmentName = dto.DepartmentName,
                    ManagerPerson  = dto.ManagerPerson
                };
                _context.Departments.Add(department);
            }
            _context.SaveChanges();
            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Add Department success"
            }));
        }
Exemplo n.º 4
0
        public HttpResponseMessage DeleteDepartments(List <DeleteIdDto> dtos)
        {
            if (dtos != null)
            {
                var departments = new List <Department>();
                foreach (var item in dtos)
                {
                    var department = GetDepartmentByDeleted(item);
                    if (department != null)
                    {
                        departments.Add(department);
                    }
                }

                if (departments.Count > 0)
                {
                    _context.Departments.RemoveRange(departments);
                    _context.SaveChanges();

                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Delete department success"
                    }));
                }

                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't find department with list Id"
                }));
            }

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.BadRequest,
                ErrorMessage = "",
                ResponseMessage = "Parammeter is not invalid"
            }));
        }
Exemplo n.º 5
0
        public HttpResponseMessage DeleteJoinBuidings(List <DeleteIdDto> dtos)
        {
            if (dtos != null)
            {
                var joinBuidings = new List <JoinBuiding>();
                foreach (var item in dtos)
                {
                    var joinBuiding = GetJoinBuidingByDeleted(item);
                    if (joinBuiding != null)
                    {
                        joinBuidings.Add(joinBuiding);
                    }
                }

                if (joinBuidings.Count > 0)
                {
                    _context.JoinBuidings.RemoveRange(joinBuidings);
                    _context.SaveChanges();

                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Delete JoinBuiding success"
                    }));
                }

                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't find JoinBuiding with list Id"
                }));
            }

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.BadRequest,
                ErrorMessage = "",
                ResponseMessage = "Parammeter is not invalid"
            }));
        }
        public HttpResponseMessage DeleteEmployees(List <DeleteIdDto> dtos)
        {
            if (dtos != null)
            {
                var employees = new List <Employee>();
                foreach (var item in dtos)
                {
                    var employee = GetEmployeeByDeleted(item);
                    if (employee != null)
                    {
                        employees.Add(employee);
                    }
                }

                if (employees.Count > 0)
                {
                    _context.Employees.RemoveRange(employees);
                    _context.SaveChanges();

                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Delete Employee success"
                    }));
                }

                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't find Employee with list Id"
                }));
            }

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.BadRequest,
                ErrorMessage = "",
                ResponseMessage = "Parammeter is not invalid"
            }));
        }
Exemplo n.º 7
0
        public HttpResponseMessage DeleteDepartment(DeleteIdDto dto)
        {
            var department = GetDepartmentByDeleted(dto);

            // Xoa Cung
            if (department == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't not find department with list Id " + dto.Id
                }));
            }
            _context.Departments.Remove(department);
            _context.SaveChanges();

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Delete department Width Id " + dto.Id + " success"
            }));
        }
Exemplo n.º 8
0
        public HttpResponseMessage DeleteJoinBuiding(DeleteIdDto dto)
        {
            var joinBuiding = GetJoinBuidingByDeleted(dto);

            // Xoa Cung
            if (joinBuiding == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't not find JoinBuiding with list Id " + dto.Id
                }));
            }
            _context.JoinBuidings.Remove(joinBuiding);
            _context.SaveChanges();

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Delete JoinBuiding Width Id " + dto.Id + " success"
            }));
        }
        public HttpResponseMessage DeleteDepartment(DeleteIdDto dto)
        {
            var employee = GetEmployeeByDeleted(dto);

            // Xoa Cung
            if (employee == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.OK,
                    ErrorMessage = "",
                    ResponseMessage = "Can't not find Employee with list Id " + dto.Id
                }));
            }
            _context.Employees.Remove(employee);
            _context.SaveChanges();

            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Delete Employee Width Id " + dto.Id + " success"
            }));
        }
        public HttpResponseMessage AddNewOrEditEmployee(EmployeeDto dto)
        {
            if (dto == null)
            {
                return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    ErrorMessage = "Parammeter null",
                    ResponseMessage = ""
                }));
            }

            if (dto.Id != Guid.Empty)
            {
                var employee = GetEmployeeById(dto.Id);
                if (employee != null)
                {
                    employee.Name         = dto.Name;
                    employee.Birthday     = dto.Birthday;
                    employee.Address      = dto.Address;
                    employee.Salary       = dto.Salary;
                    employee.Phone        = dto.Phone;
                    employee.Gmail        = dto.Gmail;
                    employee.Gender       = dto.Gender;
                    employee.Status       = dto.Status;
                    employee.DepartmentId = dto.DepartmentId;
                    employee.UpdateDate   = DateTime.Now;
                }
                else
                {
                    return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
                    {
                        StatusCode = HttpStatusCode.OK,
                        ErrorMessage = "",
                        ResponseMessage = "Can't Find Employee Width Id" + dto.Id
                    }));
                }
            }
            else
            {
                var employee = new Employee()
                {
                    Name         = dto.Name,
                    Birthday     = dto.Birthday,
                    Address      = dto.Address,
                    Salary       = dto.Salary,
                    Phone        = dto.Phone,
                    Gmail        = dto.Gmail,
                    Gender       = dto.Gender,
                    Status       = dto.Status,
                    DepartmentId = dto.DepartmentId
                };
                _context.Employees.Add(employee);
            }
            _context.SaveChanges();
            return(RespronMessageHelper.ResponseMessage(Request, new RespronseDto
            {
                StatusCode = HttpStatusCode.OK,
                ErrorMessage = "",
                ResponseMessage = "Add Employee success"
            }));
        }