public void UpdateVendor() { if (!ValidateVendorDetails()) { return; } VendorPost vendorPost = new VendorPost(); vendorPost.ID = int.Parse(m_UIControl.tb_vendorId.Text.Trim()); vendorPost.CompanyName = m_UIControl.tb_companyName.Text.Trim(); vendorPost.Address = m_UIControl.tb_address.Text.Trim(); vendorPost.Email = m_UIControl.tb_email.Text.Trim(); vendorPost.MobileNumber = m_UIControl.tb_mobileNumber.Text.Trim(); vendorPost.City = m_UIControl.tb_city.Text.Trim(); vendorPost.State = m_UIControl.tb_state.Text.Trim(); var vendorGet = DataService.GetVendorDataController().Put(vendorPost); if (vendorGet == null) { Assert.Do("Failed to edit vendor"); return; } MessageBox.Show("Vendor Updated Successfully"); ResetTextBoxes(); m_UIControl.DialogResult = DialogResult.OK; // fire vendor updated event Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.VENDOR, vendorGet.ID); EventBroadcaster.Get().BroadcastEvent(e); }
public VendorGet Post(VendorPost post) { var vendorDTO = new VendorDTO(post); m_Context.Vendors.Add(vendorDTO); m_Context.SaveChanges(); if (vendorDTO == null) { return(null); } return(new VendorGet(m_Context, vendorDTO)); }
public VendorGet Put(VendorPost post) { var vendorDTO = m_Context.GetVendor(post.ID); if (vendorDTO == null) { return(null); } vendorDTO.CopyFrom(post); m_Context.Entry(vendorDTO).State = EntityState.Modified; m_Context.SaveChanges(); return(new VendorGet(m_Context, vendorDTO)); }
public VendorGet AddNewVendor() { if (!ValidateVendorDetails()) { return(null); } VendorPost vendor = new VendorPost(); vendor.CompanyName = m_UIControl.tb_companyName.Text.Trim(); vendor.Address = m_UIControl.tb_address.Text.Trim(); vendor.Email = m_UIControl.tb_email.Text.Trim(); vendor.MobileNumber = m_UIControl.tb_mobileNumber.Text.Trim(); vendor.City = m_UIControl.tb_city.Text.Trim(); vendor.State = m_UIControl.tb_state.Text.Trim(); var vendorGet = DataService.GetVendorDataController().Post(vendor); if (vendorGet == null) { Assert.Do("Failed to add vendor"); return(null); } MessageBox.Show("Vendor Added Successfully"); ResetTextBoxes(); Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.VENDOR, vendorGet.ID); EventBroadcaster.Get().BroadcastEvent(e); if (!m_UIControl.checkBox_AddAnotherVendor.Checked) { m_UIControl.DialogResult = DialogResult.OK; m_UIControl.Close(); } return(vendorGet); }
public VendorDTO(VendorPost vendorPOST) : base(vendorPOST) { }