コード例 #1
0
        public async Task <ActionResultReponese <string> > InsertAsync(string idDepartment, IndustryMeta industryMeta)
        {
            var isdepartment = await _iDepartmentRepository.CheckExitsByIdDepartment(idDepartment);

            if (!isdepartment)
            {
                return(new ActionResultReponese <string>(-21, "IdDepartment khong ton tai", "Department"));
            }

            var isnameIndustry = await _iindustryRepository.checkexitNameIndustry(industryMeta.NameIndustry);

            if (isnameIndustry)
            {
                return(new ActionResultReponese <string>(-31, "NameIndustry da ton tai", "Industry"));
            }

            var _industry = new Industry
            {
                IdIndustry   = Guid.NewGuid().ToString(),
                NameIndustry = industryMeta.NameIndustry?.Trim(),
                IdDepartment = idDepartment?.Trim(),
                Address      = industryMeta.Address?.Trim(),
                Email        = industryMeta.Email?.Trim(),
                PhoneNumber  = industryMeta.PhoneNumber?.Trim(),
                Details      = industryMeta.Details?.Trim(),
                CreateDate   = DateTime.Now,
                Deletetime   = null,
                LastUpdate   = null,
                IsActive     = true,
                IsDelete     = false,
            };
            var code = await _iindustryRepository.InsertAsync(_industry);

            if (code >= 0)
            {
                return(new ActionResultReponese <string>(code, "Insert thanh cong", "Industry"));
            }
            return(new ActionResultReponese <string>(code, "Insert that bai", "Industry"));
        }
コード例 #2
0
        public async Task <ActionResultReponese <string> > InsertAsync(string idTeacher, string idDepartment, TeacherMeta teacherMeta)
        {
            var teacheId = Guid.NewGuid().ToString();

            var isNameExit = await _teacheRepository.CheckIdTeacherAsync(idTeacher);

            if (isNameExit)
            {
                return(new ActionResultReponese <string>(-2, "IdTeacher da ton tai", "Teacher"));
            }


            var isCheckDepartment = await _departmentRepository.CheckExitsByIdDepartment(idDepartment);

            if (!isCheckDepartment)
            {
                return(new ActionResultReponese <string>(-3, "IdDepartment khong ton tai", "Department"));
            }

            var teache = new Teachers
            {
                Id             = teacheId,
                IdTeacher      = idTeacher?.Trim(),
                NameTeacher    = teacherMeta.NameTeacher?.Trim(),
                IdDepartment   = idDepartment?.Trim(),
                Note           = teacherMeta.Note?.Trim(),
                WorkingCompany = teacherMeta.WorkingCompany?.Trim(),
                PhoneNumber    = teacherMeta.PhoneNumber?.Trim(),
                Email          = teacherMeta.Email?.Trim(),
                CountTopics    = teacherMeta.CountTopics,
                CreateDate     = DateTime.Now,
                IsActive       = true,
                LastUpdate     = null,
                IsDelete       = false,
                IsTopicsFull   = false,
            };

            var result = await _teacheRepository.InsertAsync(teache);

            if (result >= 0)
            {
                return(new ActionResultReponese <string>(result, "Insert Thanh cong", "Teacher"));
            }
            return(new ActionResultReponese <string>(result, "Insert that bai", "Teacher"));
        }