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

            try
            {
                ContactInfo  contactInfo = _dbContext.ContactInfoes.Where(x => x.ContactInfoID == contactInfoId).Single();
                PropertyInfo prop        = contactInfo.GetType().GetProperty(field);
                prop.SetValue(contactInfo, value);
                await _dbContext.SaveChangesAsync();

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