Пример #1
0
        public async Task <Object> UpdateCustomerContactField(int customerContactId, string field, string value)
        {
            if (String.IsNullOrWhiteSpace(value))
            {
                value = null;
            }

            try
            {
                CustomerContact customerContact = _dbContext.CustomerContacts.Where(x => x.CustomerContactID == customerContactId).Single();
                PropertyInfo    prop            = customerContact.GetType().GetProperty(field);
                prop.SetValue(customerContact, value);
                await _dbContext.SaveChangesAsync();

                return(new { success = true, responseText = "Customer contact updated" });
            }
            catch (Exception ex)
            {
                return(new { success = false, responseText = "Customer contact update failed" });
            }
        }