Example #1
0
        public async Task <List <MN_Contact> > GetListByCustomer(string customerid)
        {
            var query = new StringBuilder();

            query.AppendLine("{");

            query.AppendLine("'CustomerId': { '$eq' : '" + customerid + "' }");

            query.AppendLine("}");

            return(await _MN_ContactRepository.GetManyToList(MongoHelper.ConvertQueryStringToDocument(query.ToString())));
        }
Example #2
0
        public async Task <MN_CustomerDetailCustomView> GetCustomById(string id)
        {
            var model = new MN_CustomerDetailCustomView();

            try
            {
                //Lấy người khách hàng
                var objCustomer = await _MN_CustomerRepository.GetOneById(id);

                //Lấy nhóm khách hàng
                var objCustomerGroup = await _MN_CustomerGroupRepository.GetOneById(objCustomer.CustomerGroupId);

                //Lấy danh sách contacts
                var query = new StringBuilder();
                query.AppendLine("{");
                query.AppendLine("'CustomerId' : { '$eq': '" + objCustomer.Id + "' }");
                query.AppendLine("}");

                var listContacts = await _MN_ContactRepository.GetManyToList(MongoHelper.ConvertQueryStringToDocument(query.ToString()));

                //Mapping
                model = new MN_CustomerDetailCustomView()
                {
                    Id                = objCustomer.Id,
                    Name              = objCustomer.Name,
                    Description       = objCustomer.Description,
                    Note              = objCustomer.Note,
                    CustomerGroupName = objCustomerGroup.Name,
                    Contacts          = listContacts
                };
            }
            catch
            {
                model = new MN_CustomerDetailCustomView()
                {
                    Id                = "",
                    Name              = "Không tồn tại",
                    Description       = "Không tồn tại",
                    Note              = "Không tồn tại",
                    CustomerGroupName = "",
                    Contacts          = new List <MN_Contact>()
                };
            }

            return(model);
        }