//Update
        public string update(CustomerRelationshipDto tCustomerRelationshipDto)
        {
            try
            {
                CustomerRelationship tCustomerRelationshipUpdate = _context.CustomerRelationship.Find(tCustomerRelationshipDto.Id);
                if (tCustomerRelationshipUpdate == null)
                {
                    return("1");
                }
                tCustomerRelationshipUpdate.Id   = tCustomerRelationshipDto.Id;
                tCustomerRelationshipUpdate.Name = tCustomerRelationshipDto.Name;

                tCustomerRelationshipUpdate.Status     = tCustomerRelationshipDto.Status;
                tCustomerRelationshipUpdate.CreateDate = tCustomerRelationshipDto.CreateDate;
                tCustomerRelationshipUpdate.CreateUser = tCustomerRelationshipDto.CreateUser;

                _context.CustomerRelationship.Update(tCustomerRelationshipUpdate);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
        public string create(CustomerRelationshipDto tCustomerRelationshipDto)
        {
            try
            {
                CustomerRelationship tCustomerRelationshipNew = mapper.Map <CustomerRelationshipDto, CustomerRelationship>(tCustomerRelationshipDto);
                tCustomerRelationshipNew.Id         = Guid.NewGuid().ToString();
                tCustomerRelationshipNew.CreateDate = DateTime.Now;

                _context.CustomerRelationship.Add(tCustomerRelationshipNew);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Esempio n. 3
0
        public IActionResult Update([FromBody] CustomerRelationshipDto value)
        {
            string result = _crService.update(value);

            return(new ObjectResult(result));
        }