コード例 #1
0
 public ActionResult <ReturnMessageDTO> GetSystemCode(string runningCode, params string[] parameter)
 {
     try
     {
         parameter = parameter.Select(x => x.ToUpper()).ToArray();
         ReturnMessageDTO returnMessageDTO = RunningNoService.GenerateRunningNo(runningCode, parameter);
         return(returnMessageDTO);
     }
     catch (Exception ex)
     {
         return(NotFound(ex.Message));
     }
 }
コード例 #2
0
        //เพิ่ม ข้อมูล project ลง DB
        public async Task <string> CreateProject(ProjectDTO addProject)
        {
            try
            {
                PjManageProject check = Context.PjManageProject.Where(x => x.ProjectName == addProject.ProjectName && x.Active == true).FirstOrDefault();
                if (addProject == null)
                {
                    throw new Exception("Please fill out the information.");
                }
                if (check != null)
                {
                    throw new Exception("This project already exists.");
                }
                PjManageProject newData = new PjManageProject();
                newData.ProjectCode = (await ProjectRunning.GenerateRunningNo("PJ")).Code;
                newData.ProjectName = addProject.ProjectName;
                newData.CompanyCode = addProject.Company;
                newData.Active      = true;
                newData.Deseription = addProject.Deseription;
                newData.StartDate   = addProject.StartDate;
                newData.EndDate     = addProject.EndDate;
                newData.PmManday    = addProject.PmManday;
                newData.SaManday    = addProject.SaManday;
                newData.SdManday    = addProject.SdManday;
                newData.Status      = addProject.Status;
                newData.CreatedBy   = null;
                newData.CreatedDate = DateTime.Now;
                newData.UpdatedBy   = null;
                newData.UpdatedDate = DateTime.Now.AddYears(3);
                CreateEmployee(addProject.Team, newData.ProjectCode);// แยกไปใช้อีกฟังชัน
                Context.PjManageProject.Add(newData);
                Context.SaveChanges();

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }