Beispiel #1
0
        private bool InsertCustomerContactToDb(DMCustomerContact customerContact, Guid userGuid)
        {
            var contact = (DMCustomerContact)MapperHelper.SetDefaultValueToNullProperty(customerContact);
            var entity  = MapCustomerContactToCoreCustomerContact(contact, userGuid);

            _customerContactService.Add(entity);
            return(true);
        }
        public IActionResult Add([FromBody] ContactViewModel contactViewModel)
        {
            try
            {
                Guid id = Guid.NewGuid();
                var  customerContact = ObjectMapper <ContactViewModel, CustomerContact> .Map(contactViewModel);

                customerContact.ContactTypeGuid = contactViewModel.ContactType;
                customerContact.ContactGuid     = id;
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                customerContact.CreatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                customerContact.CreatedBy = UserHelper.CurrentUserGuid(HttpContext);
                customerContact.UpdatedOn = CurrentDateTimeHelper.GetCurrentDateTime();
                customerContact.UpdatedBy = UserHelper.CurrentUserGuid(HttpContext);
                customerContact.IsActive  = true;
                customerContact.IsDeleted = false;
                var CustomerContact = _customerContactService.Add(customerContact);
                var jsonObjects     = new
                {
                    contactguid         = customerContact.ContactGuid,
                    searchvalue         = customerContact.SearchValue,
                    customerguid        = customerContact.CustomerGuid,
                    customerName        = customerContact.CustomerName,
                    customerLastName    = customerContact.LastName,
                    customerPhoneNumber = customerContact.PhoneNumber,
                    fullName            = Infrastructure.Helpers.FormatHelper.FormatFullName(customerContact.FirstName, customerContact.MiddleName, customerContact.LastName)
                };
                return(Ok(new { status = ResponseStatus.success.ToString(), message = "Successfully Added !!", CustomerContact = jsonObjects }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }