// GET: Customer
        public ActionResult CustomerList()
        {
            _repositorycustomer = new RepositoryCustomer();
            var list = _repositorycustomer.GetListcustomer();

            return(View(list));
        }
        private void loadCustomer()
        {
            var listcustomer = _repositoryCustomer.GetListcustomer();

            listcustomer.Add(new Customer {
                CustomerId = -1, CustomerName = "ALL"
            });
            ViewBag.CustomerId = new SelectList(listcustomer, "CustomerId", "CustomerName", -1);
        }
        public ActionResult CreateProject()
        {
            _repositoryCustomer = new RepositoryCustomer();
            _repositoryStaff    = new RepositoryStaff();
            var listcustomer = _repositoryCustomer.GetListcustomer();

            ViewBag.CustomerId = new SelectList(listcustomer, "CustomerId", "CustomerName");

            loadStaf();

            return(View());
        }
        public ActionResult Edit(int id)
        {
            _repositoryCustomer = new RepositoryCustomer();
            _repositoryProject  = new RepositoryProject();
            _repositoryStaff    = new RepositoryStaff();

            var project = _repositoryProject.GetProjectByProjectId(id, p => p.ProjectStaffs);



            var listcustomer = _repositoryCustomer.GetListcustomer();

            ViewBag.CustomerId = new SelectList(listcustomer, "CustomerId", "CustomerName", project.CustomerId);

            loadStafEdit(project);
            return(View(project));
        }
        public ActionResult Edit(Project project, string CMStaff, string PMStaff, string PDEStaff, string SEStaff, string QEStaff, string DRStaff)
        {
            _repositoryProject  = new RepositoryProject();
            _repositoryCustomer = new RepositoryCustomer();
            int projectoldid = Convert.ToInt32(ViewBag.projectidold);

            var projectedit = _repositoryProject.GetProjectByProjectId(project.ProjectID, p => p.ProjectStaffs);

            projectedit.ProjectStaffs.CMStaff  = CMStaff;
            projectedit.ProjectStaffs.PMStaff  = PMStaff;
            projectedit.ProjectStaffs.PDEStaff = PDEStaff;
            projectedit.ProjectStaffs.SEStaff  = SEStaff;
            projectedit.ProjectStaffs.QEStaff  = QEStaff;
            projectedit.ProjectStaffs.DRStaff  = DRStaff;
            projectedit.ProjectID  = project.ProjectID;
            projectedit.Status     = project.Status;
            projectedit.CustomerId = project.CustomerId;

            projectedit.ProjectStatus = Status.Modify;



            if (ModelState.IsValid)
            {
                projectedit.ProjectStatus = Status.Modify;
                OperationStatus ops = _repositoryProject.SaveProject(projectedit);
                if (ops.Status)
                {
                    return(RedirectToAction("ProjectList", new { PMStaff = PMStaff }));
                }
                else
                {
                    ModelState.AddModelError("", ops.ExceptionInnerMessage);
                }
            }
            var listcustomer = _repositoryCustomer.GetListcustomer();

            _repositoryStaff = new RepositoryStaff();
            loadStaf();
            ViewBag.CustomerId = new SelectList(listcustomer, "CustomerId", "CustomerName");

            return(View());
        }
        public ActionResult CreateProject(Project project, string CMStaff, string PMStaff, string PDEStaff, string SEStaff, string QEStaff, string DRStaff)
        {
            _repositoryProject    = new RepositoryProject();
            _repositoryCustomer   = new RepositoryCustomer();
            project.ProjectStaffs = new ProjectStaff();

            //int projectid = project.ProjectID;

            project.ProjectStaffs.CMStaff  = CMStaff;
            project.ProjectStaffs.PMStaff  = PMStaff;
            project.ProjectStaffs.PDEStaff = PDEStaff;
            project.ProjectStaffs.SEStaff  = SEStaff;
            project.ProjectStaffs.QEStaff  = QEStaff;
            project.ProjectStaffs.DRStaff  = DRStaff;
            //project.ProjectStaffs.ProjectId = projectid;

            project.Create = DateTime.Now;

            var listcustomer = _repositoryCustomer.GetListcustomer();


            if (ModelState.IsValid)
            {
                project.ProjectStatus = Status.Add;
                OperationStatus ops = _repositoryProject.SaveProject(project);
                if (ops.Status)
                {
                    return(RedirectToAction("ProjectList"));
                }
                else
                {
                    ModelState.AddModelError("", ops.ExceptionInnerMessage);
                }
            }

            _repositoryStaff = new RepositoryStaff();
            loadStaf();
            ViewBag.CustomerId = new SelectList(listcustomer, "CustomerId", "CustomerName");

            return(View());
        }