Esempio n. 1
0
        public IActionResult Insert(InsertVendorDTO dTO)
        {
            var result = _service.Insert(dTO);

            if (result)
            {
                return(Ok());
            }
            else
            {
                throw new Exception();
            }
        }
Esempio n. 2
0
        public async Task <ResponseInsertDTO> Insert(InsertVendorDTO DTO)

        {
            var TagList = new List <Tag>();

            if (DTO.Tags != null && DTO.Tags.Count > 0)
            {
                foreach (var item in DTO.Tags)
                {
                    Tag tag = new Tag();
                    tag.NameTag = item.NameTag;
                    TagList.Add(tag);
                }
            }

            var vendor = new vendor()
            {
                VendorName  = DTO.VenderName,
                Title       = DTO.Title,
                PhoneNumber = DTO.PhoneNumber,
                Address     = DTO.Address,
                Tag         = TagList
            };

            var vender = await _repository.InsertVendor(vendor);

            ResponseInsertDTO response = new ResponseInsertDTO()
            {
                Id          = vender.Id,
                VenderName  = vender.VendorName,
                Title       = vender.Title,
                PhoneNumber = vender.PhoneNumber,
                Address     = vender.Address,
                NameTag     = vender.Tag.Select(t => t.NameTag).ToList()
            };

            return(response);
        }
Esempio n. 3
0
        public bool Insert(InsertVendorDTO DTO)
        {
            bool result = false;

            var TagList = new List <Tag>();

            if (DTO.Tags != null && DTO.Tags.Count > 0)
            {
                foreach (var item in DTO.Tags)
                {
                    Tag tag = new Tag();
                    tag.NameTag = item.NameTag;
                    TagList.Add(tag);
                }
            }

            var vendor = new vendor()
            {
                VendorName  = DTO.VenderName,
                Title       = DTO.Title,
                PhoneNumber = DTO.PhoneNumber,
                Address     = DTO.Address,
                Tag         = TagList
            };

            int insertedvendor = _repository.InsertVendor(vendor);

            if (insertedvendor > 0)
            {
                if (insertedvendor > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
        public async Task <IActionResult> Insert(InsertVendorDTO dTO)
        {
            var result = (await _service.Insert(dTO));

            return(Created(nameof(getallById), result));
        }