public void UpdatePhone(Phone phone)
        {
            var foundPhone = _dataSource.Phones.FirstOrDefault(p => p.PhoneId == phone.PhoneId);
            if (foundPhone == null)
            {
                return;
            }

            foundPhone.Number = phone.Number;
            foundPhone.PhoneType = phone.PhoneType;
        }
Exemple #2
0
 public static object CreatePhone(Phone phone)
 {
     try
     {
         var addedPhone = _repository.PhoneRepository.AddPhone(phone);
         return new { Result = "OK", Record = addedPhone };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
        public JsonResult CreatePhone(Phone phone)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." });
                }

                var addedPhone = _repository.PhoneRepository.AddPhone(phone);
                return Json(new { Result = "OK", Record = addedPhone });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemple #4
0
 public static object UpdatePhone(Phone phone)
 {
     try
     {
         _repository.PhoneRepository.UpdatePhone(phone);
         return new { Result = "OK" };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
 public Phone AddPhone(Phone phone)
 {
     phone.PhoneId = _dataSource.Phones.Count > 0 ? (_dataSource.Phones[_dataSource.Phones.Count - 1].PhoneId + 1) : 1;
     _dataSource.Phones.Add(phone);
     return phone;
 }
Exemple #6
0
 public static object UpdatePhone(Phone record)
 {
     return DemoMethods.UpdatePhone(record);
 }
Exemple #7
0
 public static object CreatePhone(Phone record)
 {
     return DemoMethods.CreatePhone(record);
 }