Пример #1
0
        public CDataResults <CRelationListDto> GetRelations(CRelationInput input)
        {
            if (!checkCustomer(input.customer_id))
            {
                AddVisitRecord(input.customerId, Entities.VisitRecordFlag.Black);
                return(new CDataResults <CRelationListDto>()
                {
                    IsSuccess = false,
                    ErrorMessage = "Validation failed.",
                    Data = null
                });
            }
            //var siteList = this._cstnInfoRepository.GetAll().OrderBy(order => order.areaName);
            var relationList = this._relationRepository.GetAll().Where(p => p.customer_id == (input.customer_id));
            var result       = relationList.ToList().MapTo <List <CRelationListDto> >();

            AddVisitRecord(input.customerId, Entities.VisitRecordFlag.White);
            return(new CDataResults <CRelationListDto>()
            {
                IsSuccess = true,
                ErrorMessage = null,
                Data = result,
                Total = relationList.Count()
            });
        }
Пример #2
0
        public CDataResults <CRelationListDto> AddRelations(CRelationInput input)
        {
            if (!checkCustomer(input.customer_id))
            {
                AddVisitRecord(input.customerId, Entities.VisitRecordFlag.Black);
                return(new CDataResults <CRelationListDto>()
                {
                    IsSuccess = false,
                    ErrorMessage = "Validation failed.",
                    Data = null
                });
            }

            if (input.siteIdArr.Count > 0)
            {
                _relationRepository.Delete(d => d.customer_id == input.customer_id);

                foreach (var item in input.siteIdArr)
                {
                    Entities.CRelation entity = new Entities.CRelation()
                    {
                        customer_id = input.customer_id,
                        site_id     = item
                    };
                    _relationRepository.Insert(entity);
                }
                ;
            }
            AddVisitRecord(input.customerId, Entities.VisitRecordFlag.White);
            return(new CDataResults <CRelationListDto>()
            {
                IsSuccess = true,
                ErrorMessage = null,
                Data = null
            });
        }