Esempio n. 1
0
        public CommunityBusinessRelationOutputDto AddCommunityBusinessRelation(CommunityBusinessRelationInputDto input)
        {
            var community = _communityInfoRepository.Get(input.CommunityId);
            var business  = _communityBusinessRepository.Get(input.BusinessId);

            if (community == null || business == null)
            {
                Error.Execute("社区或业务不存在!");
                return(null);
            }

            var relation = _communityBusinessRelationRepository.Get(x =>
                                                                    x.Businessid.Equals(input.BusinessId) && x.Communityid.Equals(input.CommunityId));

            if (relation != null)
            {
                Error.Execute("社区业务已关联!");
                return(null);
            }

            input.id = Guid.NewGuid().ToString();
            var model = Mapper.Map <SSS.Domain.Community.CommunityBusinessRelation.CommunityBusinessRelation>(input);

            model.CreateTime = DateTime.Now;
            model.IsDelete   = 0;

            _communityBusinessRelationRepository.Add(model);
            return(_communityBusinessRelationRepository.SaveChanges() > 0 ? Mapper.Map <CommunityBusinessRelationOutputDto>(model) : null);
        }
Esempio n. 2
0
        public CommunityTaskOutputDto AddCommunityTask(CommunityTaskInputDto input)
        {
            var result = Validator.Validate(input, ruleSet: "Insert");

            if (!result.IsValid)
            {
                Error.Execute(result);
                return(null);
            }

            var business = _communityBusinessRepository.Get(input.businessid);

            if (business == null)
            {
                Error.Execute("ÒµÎñ²»´æÔÚ£¡");
                return(null);
            }

            input.id = Guid.NewGuid().ToString();
            var model = Mapper.Map <SSS.Domain.Community.CommunityTask.CommunityTask>(input);

            model.CreateTime = DateTime.Now;
            Repository.Add(model);
            return(Repository.SaveChanges() > 0 ? Mapper.Map <CommunityTaskOutputDto>(model) : null);
        }