예제 #1
0
 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();
 }
예제 #2
0
        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();
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
 public void Edit(int telephoneId, Telephone telephone)
 {
     _telephoneRepository.Edit(telephoneId, telephone);
 }
예제 #5
0
 public void Add(int customerId, Telephone telephone)
 {
     _telephoneRepository.Add(customerId, telephone);
 }
예제 #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);
 }
예제 #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;
 }