Beispiel #1
0
        public async Task <IActionResult> CreateDepartment([FromBody] CreateDepartmentModel createDepartmentModel)
        {
            CreateDepartmentDto createDepartmentDto = _mapper.Map <CreateDepartmentDto>(createDepartmentModel);
            await _departmentService.CreateDepartmentAsync(createDepartmentDto);

            return(Ok());
        }
Beispiel #2
0
        public CreateDepartmentResult CreateDepartment(CreateDepartmentDto dto)
        {
            //dto.AccessToken = GetAccessToken(QyConfig.CorpID, QyConfig.CorpSecret);
            var result = MailListApi.CreateDepartment(dto.AccessToken, dto.Name, dto.ParentId, dto.Order, dto.ID);

            return(result);
        }
Beispiel #3
0
        public async Task Create(CreateDepartmentDto input)
        {
            var @department = input.MapTo <Department>();

            @department = Department.Create(AbpSession.GetTenantId(), input.Name, input.BarcodeNo, input.Length, input.Width, input.Remark);
            await _departmentRepository.InsertAsync(@department);
        }
Beispiel #4
0
        public GetDepartmentDto Add(CreateDepartmentDto createDepartmentDto)
        {
            var department     = _mapper.Map <Department>(createDepartmentDto);
            var departmentInDb = _unitOfWork.DepartmentRepository.Add(department);

            _unitOfWork.SaveChanges();
            return(_mapper.Map <GetDepartmentDto>(departmentInDb));
        }
        public async Task <IHttpActionResult> CreateDepartment(CreateDepartmentDto item)
        {
            //TODO: validate
            item.CreatedBy = CurrentUser.Id;
            var result = await _departmentServices.CreateAsync(item);

            return(Ok(result));
        }
Beispiel #6
0
        public async Task <Department> AddDepartmentAsync(CreateDepartmentDto departmentDto)
        {
            var department = _mapper.Map <Department>(departmentDto);

            _context.Departments.Add(department);
            await _context.SaveChangesAsync();

            return(department);
        }
Beispiel #7
0
        public IActionResult CreateDepartment([FromBody] CreateDepartmentDto newDep)
        {
            var newDepartment = _departmentService.CreateDepartment(newDep);

            if (newDepartment == null)
            {
                return(BadRequest());
            }
            return(CreatedAtRoute("GetDepartmentById", new { id = newDepartment.Item2.Identifier }, newDepartment.Item1));
        }
Beispiel #8
0
        /// <summary>
        /// 创建部门
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <CreateDepartmentModel> CreateDepartment(CreateDepartmentDto dto)
        {
            string url = $"https://api.exmail.qq.com/cgi-bin/department/create?access_token={this.Email_token}";
            CreateDepartmentModel model = await HttpHelper.PostHttpAsync <CreateDepartmentModel, CreateDepartmentDto>(url, dto);

            if (model.Errcode != 0)
            {
                this.Errmsg = model.Errmsg;
                throw new Exception($"创建部门失败:{model.Errcode}-{this.Errmsg}");
            }
            return(await Task.FromResult(model));
        }
Beispiel #9
0
        public Tuple <DepartmentReturnDto, LinkDto> CreateDepartment(CreateDepartmentDto newDepartment)
        {
            if (!_userOperations.UserExists(newDepartment.ManagerId))
            {
                return(null);
            }
            var user = _userOperations.GetUserById(newDepartment.ManagerId);
            var createdDepartment = _departmentOperations.CreateDepartment(newDepartment.DepartmentName, user);

            _userOperations.UpdateUserDepartment(user, createdDepartment);
            return(new Tuple <DepartmentReturnDto, LinkDto>(Mapper.Map <DepartmentReturnDto>(createdDepartment), CreateLink(createdDepartment.DepartmentID, "GetDepartmentById", this._urlHelper)));
        }
        public async Task <Guid> CreateAsync(CreateDepartmentDto item)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var entity = Department.Create(item.Name,
                                               item.Code, item.ParentID, item.DeptTypeID, item.DeptGroupID,
                                               item.OrderNumber.HasValue ? item.OrderNumber.Value : 99, item.IsPrint,
                                               item.IsShow, item.CreatedBy);
                _deparmentRepository.Add(entity);
                await scope.SaveChangesAsync();

                return(entity.Id);
            }
        }
Beispiel #11
0
        public async Task <int> CreateAsync(CreateDepartmentDto createDepartmentDto)
        {
            createDepartmentDto.ThrowIfNull(nameof(createDepartmentDto));

            ////Guard.Against.Null(createDepartmentDto, nameof(createDepartmentDto));

            Department departmentToBeCreated = new Department()
            {
                Name        = createDepartmentDto.DepartmentName,
                Description = createDepartmentDto.Description
            };

            int departmentId = await _departmentCacheRepository.InsertAsync(departmentToBeCreated);

            return(departmentId);
        }
        public async Task CreateDepartmentAsync(CreateDepartmentDto createDepartmentDto)
        {
            if (createDepartmentDto == null)
            {
                throw new ArgumentNullException(nameof(createDepartmentDto));
            }

            Department departmentToBeCreated = new Department()
            {
                DepartmentName = createDepartmentDto.DepartmentName,
                Description    = createDepartmentDto.Description
            };

            await _unitOfWork.Repository <Department>().InsertEntityAsync(departmentToBeCreated);

            await _unitOfWork.SaveChangesAsync();
        }
        public async Task <int> CreateAsync(CreateDepartmentDto request)
        {
            if (await _departmentRepository.AnyAsync(x => x.Name.Equals(request.Name)))
            {
                throw new ValidationException($"Error: {request.Name } already exist");
            }

            var department = new Department
            {
                Name        = request.Name,
                Description = request.Description
            };

            _departmentRepository.Add(department);

            return(await _unitOfWork.SaveChangesAsync());
        }
Beispiel #14
0
        public IActionResult CreateDepartment(CreateDepartmentDto createDepartmentDto)
        {
            bool isExist = _db.Departments.Any(x => x.Name.ToLower().Trim() == createDepartmentDto.Name.ToLower().Trim());

            if (createDepartmentDto == null)
            {
                return(BadRequest());
            }
            if (isExist)
            {
                ModelState.AddModelError("", "Department name is exists");
                return(StatusCode(400, ModelState));
            }

            var obj = _mapper.Map <Department>(createDepartmentDto);

            _db.Departments.Add(obj);
            _db.SaveChanges();
            return(CreatedAtRoute(nameof(GetDepartment), new { departmentId = obj.Id }, obj));
        }
Beispiel #15
0
        public async Task <ActionResult> CreateDepartment([FromBody] CreateDepartmentModel model)
        {
            try
            {
                CreateDepartmentDto createDepartmentDto = new CreateDepartmentDto
                {
                    DepartmentName = model.DepartmentName,
                    Description    = model.Description
                };

                int departmentId = await _departmentService.CreateAsync(createDepartmentDto);

                return(CreatedAtAction(nameof(GetDepartment), new { departmentId }, model));
            }
            catch (Exception exception)
            {
                await _exceptionLogger.LogAsync(exception);

                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Beispiel #16
0
        public async Task <ActionResult <Department> > CreateDepartment(CreateDepartmentDto departmentDto)
        {
            Department createdDepartment;

            try
            {
                var department = new Department()
                {
                    Name      = departmentDto.Name,
                    CompanyId = departmentDto.CompanyId
                };

                createdDepartment = await _orgStructureService.CreateDepartmentAsync(department);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(500, new { error = ex.Message }));
            }

            return(CreatedAtAction("GetDepartmentById", new { id = createdDepartment.Id }, createdDepartment));
        }
Beispiel #17
0
        private async Task CreateAsync(DepartmentDto department)
        {
            var request = new CreateDepartmentDto {
                Name = department.Name, Description = department.Description
            };

            var response = await _departmentManager.CreateAsync(request);

            if (response.Succeeded)
            {
                await GetAllDepartmentsWithPaging();

                DepartmentDialogVisible = false;
            }
            else
            {
                foreach (var message in response.Messages)
                {
                    await _message.Error(message);
                }
            }
        }
Beispiel #18
0
        public IActionResult Create(CreateDepartmentDto departmentDto)
        {
            var result = _departmentService.Add(departmentDto);

            return(CreatedAtAction(nameof(Get), new { id = result.Id }, result));
        }
        //[Authorize(Policy = DefaultPermissions.PermissionNameForAdministration)]
        public async Task <ActionResult <Department> > CreateDepartment(CreateDepartmentDto departmentDto)
        {
            var department = await _departmentService.AddDepartmentAsync(departmentDto);

            return(CreatedAtAction("GetDepartment", new { id = department.Id }, department));
        }
Beispiel #20
0
        public CreateDepartmentResult CreateDepartment4(CreateDepartmentDto dto)
        {
            var result = new CreateDepartmentResult();

            return(result);
        }
Beispiel #21
0
        public async Task <IResult> CreateAsync(CreateDepartmentDto request)
        {
            HttpResponseMessage response = await _httpClient.PostAsJsonAsync(Routes.DepartmentEndpoint.Create, request);

            return(await response.ToResult());
        }
Beispiel #22
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateDepartmentDto request)
        {
            await _departmentService.CreateAsync(request);

            return(Ok(await Result.SuccessAsync("Created successfully.")));
        }