コード例 #1
0
        /// <summary>
        /// Adds a new Procurement to the Procurements collection
        /// </summary>
        /// <param name="procurement">Instance of Procurement object to add to collection.</param>
        /// <returns>Newly added Procurement_ID</returns>
        public int AddProcurement(Procurement procurement)
        {
            if (procurement == null)
            {
                throw new ArgumentException("procurement was null", "procurement");
            }

            dc.Procurements.InsertOnSubmit(procurement);

            dc.SubmitChanges();

            return procurement.Procurement_ID;
        }
コード例 #2
0
 partial void DeleteProcurement(Procurement instance);
コード例 #3
0
 partial void UpdateProcurement(Procurement instance);
コード例 #4
0
 partial void InsertProcurement(Procurement instance);
コード例 #5
0
		private void detach_Procurements(Procurement entity)
		{
			this.SendPropertyChanging();
			entity.ProcurementType = null;
		}
コード例 #6
0
		private void attach_Procurements(Procurement entity)
		{
			this.SendPropertyChanging();
			entity.ProcurementType = this;
		}
コード例 #7
0
        /// <summary>
        /// Saves changes to the Procurement object passed
        /// </summary>
        /// <param name="procurement">Procurement object with changes to be saved</param>
        /// <returns>True if save was successful, false if it was not.</returns>
        public bool SaveProcurement(Procurement procurement)
        {
            if (procurement == null)
            {
                throw new ArgumentException("procurement was null", "procurement");
            }

            var old = GetProcurement(procurement.Procurement_ID);

            old = procurement;

            dc.SubmitChanges();

            // TODO: Compare object properties here
            return true;
        }
コード例 #8
0
        private void UpdateProcurementDonors(Procurement procurement, FormCollection collection)
        {
            var donorKeys = collection.AllKeys.Where(x => x.StartsWith("DonorId")).ToList();

            var donors = new List<string>();
            donorKeys.ForEach(x => donors.AddRange(collection[x].Split(',').Where(y => !string.IsNullOrEmpty(y))));

                         //collection["DonorId"].Split(',').Where(x => !string.IsNullOrEmpty(x)).ToList());

            if (donors == null) return;

            var newDonors = donors.Where(x => procurement.ProcurementDonors.Count(y => y.Donor_ID.ToString() == x ) == 0).ToList();

            var removedDonors = procurement.ProcurementDonors.Where(x => !donors.Contains(x.Donor_ID.ToString())).ToList();

            newDonors.ForEach(id => procurement.ProcurementDonors.Add(new ProcurementDonor
                                                                          {
                                                                              Donor       = Repository.GetDonor(int.Parse(id)),
                                                                              Procurement = procurement
                                                                          }));

            removedDonors.ForEach(donor => procurement.ProcurementDonors.Remove(donor));
        }
コード例 #9
0
        private void SetupProcurementDonors(Procurement procurement, FormCollection collection)
        {
            var donors = GetDonorsFromFormCollection(collection, "DonorId");

            if (donors == null) return;

            donors.ForEach(id => procurement.ProcurementDonors.Add(new ProcurementDonor
                                                                        {
                                                                            Donor = Repository.GetDonor(int.Parse(id)),
                                                                            Procurement = procurement
                                                                        }));

            // this is required until the ContactProcurement.Donor_ID column has been retired GH-15
            procurement.ContactProcurement.Donor_ID = procurement.ProcurementDonors.First().Donor_ID;
        }