public void Add(int customerId, Telephone telephone)
 {
     var addr = new Telephone
                    {
                        CustomerId = customerId,
                        PhoneNumber = telephone.PhoneNumber,
                        IsPrimary = telephone.IsPrimary,
                        ModifiedDate = DateTime.Now
                    };
     _dataContext.Telephones.AddObject(addr);
     _dataContext.SaveChanges();
 }
        public void Edit(int telephoneId, Telephone telephone)
        {
            Telephone entityToEdit = (from cust in _dataContext.Telephones
                                      where cust.Id == telephoneId
                                      select cust).FirstOrDefault();

            entityToEdit.IsPrimary = telephone.IsPrimary;
            entityToEdit.CustomerId = telephone.CustomerId;
            entityToEdit.IsPrimary = telephone.IsPrimary;
            entityToEdit.PhoneNumber = telephone.PhoneNumber;
            entityToEdit.ModifiedDate = DateTime.Now;

            _dataContext.SaveChanges();
        }
        public ActionResult Create(int customerId, Telephone telephone)
        {
            try
            {
                _repository.Add(customerId, telephone);
                var telephoneToDisplay = new TelephoneViewModel
                                             {
                                                 CustomerId = customerId,
                                                 Id = telephone.Id,
                                                 PhoneNumber = telephone.PhoneNumber,
                                                 IsPrimary = telephone.IsPrimary,
                                                 ModifiedDate = telephone.ModifiedDate
                                             };

                return RedirectToAction("Index", telephoneToDisplay);
            }
            catch
            {
                return View();
            }
        }
Example #4
0
 public void Edit(int telephoneId, Telephone telephone)
 {
     _telephoneRepository.Edit(telephoneId, telephone);
 }
Example #5
0
 public void Add(int customerId, Telephone telephone)
 {
     _telephoneRepository.Add(customerId, telephone);
 }
Example #6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Telephones EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTelephones(Telephone telephone)
 {
     base.AddObject("Telephones", telephone);
 }
Example #7
0
 /// <summary>
 /// Create a new Telephone object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="phoneNumber">Initial value of the PhoneNumber property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 /// <param name="isPrimary">Initial value of the IsPrimary property.</param>
 public static Telephone CreateTelephone(global::System.Int32 id, global::System.Int32 customerId, global::System.String phoneNumber, global::System.DateTime modifiedDate, global::System.Boolean isPrimary)
 {
     Telephone telephone = new Telephone();
     telephone.Id = id;
     telephone.CustomerId = customerId;
     telephone.PhoneNumber = phoneNumber;
     telephone.ModifiedDate = modifiedDate;
     telephone.IsPrimary = isPrimary;
     return telephone;
 }