protected Agency CaptureData() { Agency obj = new Agency(); obj.Agency_ID = txtID.Text.Trim(); obj.Agency_Name = txtName.Text.Trim(); return obj; }
public int Add(Agency newAgency) { this.agencies.Add(newAgency); this.agencies.SaveChanges(); return newAgency.Id; }
static void Main() { //var factory = new ConnectionFactory() { HostName = "localhost" }; var factory = new ConnectionFactory { Address = "192.168.1.111" }; using (var connection = factory.CreateConnection()) { using (var channel = connection.CreateModel()) { channel.ExchangeDeclare("logs", "fanout"); while (true) { var message = System.Console.ReadLine(); var agency = new Agency { Name = message }; var person = new Person { Name = message }; var json = Serializer.Serialize(new List<TBase> { agency, person }); var body = Encoding.UTF8.GetBytes(json); var basicProperties = channel.CreateBasicProperties(); basicProperties.SetPersistent(true); channel.BasicPublish("logs", "", basicProperties, body); } } } }
// Use this for initialization void Start() { parentAgency = transform.parent.GetComponent<Agency> () as Agency; Vector2 xgap = new Vector2 (128 + 16, 0 ); Vector2 ygap = new Vector2(0, 128 + 16); int n_buttons = 0; foreach (Place p in parentAgency.field.subLocations) { //build button prefab //customize button here //go.AddComponent<LocationButtonScr>(); //go.transform.SetParent (transform, false); //LocationButtonScr sc = go.GetComponent<LocationButtonScr> (); Vector2 pos = new Vector2 (0, 0); pos += xgap * (n_buttons % 4); pos -= ygap * (n_buttons / 4); //attach script GameObject go = (GameObject) Instantiate(defaultLocationButton,pos,Quaternion.identity); LocationButtonScr lbs = go.GetComponent<LocationButtonScr> (); lbs.setInfo (p, transform.GetChild (0).transform.GetChild (0).GetComponent<AgentViewbox> ()); go.transform.SetParent (transform, false); ++ n_buttons; } }
public ActionResult Agencies_Destroy([DataSourceRequest]DataSourceRequest request, Agency agency) { var agencyFromDb = this.agenciesService.GetById(agency.Id); this.agenciesService.Delete(agencyFromDb); return Json(new[] { agency }.ToDataSourceResult(request, this.ModelState)); }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { AgencyManager mgr = new AgencyManager(); Agency obj = new Agency(); obj.Agency_ID = (GridView1.SelectedDataKey).Value.ToString(); obj = mgr.selectAgency(obj); AddEditAgencyControl1.populateControls(obj); MultiView1.ActiveViewIndex = 1; }
public AgencyPlan CreateAgencyPlan(Domain.Plan.Plan plan, DateTime endDate, Agency agency) { return new AgencyPlan { Plan = plan, Agency = agency, PlanEndDate = endDate, RecruiterProducts = new List<DenormalizedReference<RecruiterProduct>>() }; }
public void populateControls(Agency obj) { Session.Remove("Flag"); Session.Add("Flag", "Edit"); btnOpt.Text = "Modify Agency"; btnDelete.Enabled = true; txtID.Text = obj.Agency_ID; txtName.Text = obj.Agency_Name; btnDelete.Enabled = true; }
public void TestProperties() { Agency agency = new Agency(); Dictionary<string, object> properties = new Dictionary<string, object>(); properties.Add("AgencyCode", "Agency01"); properties.Add("Name", "Test Agency"); properties.Add("Type", "Test"); properties.Add("DataRulesInd", "Some Value"); TestHelper.ErrorSummary errors = TestHelper.TestProperties(agency, properties); Assert.IsEmpty(errors, errors.GetSummary()); }
protected void btnSave_Click(object sender, EventArgs e) { id = int.Parse(Request.QueryString["id"]); using (CCSEntities db = new CCSEntities()) { a = (from ag in db.Agencies where ag.AgencyID == id select ag).First(); //Update simple fields if(txtAgencyName.Text != "") a.AgencyName = txtAgencyName.Text; if (txtStreet1.Text != "") a.Address.StreetAddress1 = txtStreet1.Text; if (txtStreet2.Text != "") a.Address.StreetAddress2 = txtStreet2.Text; a.Address.StateID = (short)ddlState.SelectedIndex; string zip = txtZip.Text; string city = txtCity.Text; //does new zip already exist? if ((from z in db.Zipcodes where z.ZipCode1 == zip select z).Count() > 0) { //zip already exists, use existing zip a.Address.ZipID = (from z in db.Zipcodes where z.ZipCode1 == zip select z.ZipID).First(); } else { //create new zip Zipcode z = new Zipcode(); z.ZipCode1 = zip; db.Zipcodes.Add(z); a.Address.Zipcode = z; } //Does new city already exist? if ((from c in db.Cities where c.CityName == city select c).Count() > 0) { //zip already exists, use existing zip a.Address.City = (from c in db.Cities where c.CityName == city select c).First(); } else { //create new zip City c = new City(); c.CityName = city; db.Cities.Add(c); a.Address.City = c; } db.SaveChanges(); saved.Visible = true; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { AgencyManager mgr = new AgencyManager(); Agency obj = new Agency(); obj.Agency_ID = txtID.Text.Trim(); lblError.Text = CustomErrors.CHANGES_ACCEDTED_STATUS + mgr.deleteAgency(obj); ClearControls(); } catch (Exception ex) { lblError.Text = ex.Message; } }
public ActionResult Create(Agency agency) { if (ModelState.IsValid) { try { AgencyService.AddAgency(agency); return AgencyList(); } catch (ValidationErrorsException ex) { foreach (var error in ex.Errors) { ModelState.AddModelError(error.PropertyName, error.ErrorMassage); } } } return PartialView("_Create", agency); }
/// <summary> /// Get Agency record for specified Agency ID /// </summary> /// <param name="agencyId">Agency ID</param> /// <returns>Agency object</returns> public static Agency GetAgency(string agencyId) { Agency agency = new Agency(); SqlConnection connection = TravelExpertsDB.GetConnection(); string query = "SELECT AgencyId, AgencyAddress, AgencyCity, AgencyProv, " + " AgencyPostal, AgencyCountry, AgencyPhone, AgencyFax, AgencyMap " + " FROM Agencies " + " WHERE AgencyId = @AgencyId"; SqlCommand command = new SqlCommand( query, connection); command.Parameters.AddWithValue("@AgencyId", agencyId); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { agency.AgencyId = Convert.ToInt32(reader["AgencyId"]); agency.AgencyAddress = reader["AgencyAddress"].ToString(); agency.AgencyCity = reader["AgencyCity"].ToString(); agency.AgencyProv = reader["AgencyProv"].ToString(); agency.AgencyPostal = reader["AgencyPostal"].ToString(); agency.AgencyCountry = reader["AgencyCountry"].ToString(); agency.AgencyPhone = reader["AgencyPhone"].ToString(); agency.AgencyFax = reader["AgencyFax"].ToString(); agency.AgencyMap = reader["AgencyMap"].ToString(); } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return agency; }
/// <summary> /// Get List of all Agency records /// </summary> /// <returns>List of Agency objects</returns> public static List<Agency> GetAgencies() { List<Agency> agencies = new List<Agency>(); SqlConnection connection = TravelExpertsDB.GetConnection(); string query = "SELECT AgencyId, AgencyAddress, AgencyCity, AgencyProv, " + " AgencyPostal, AgencyCountry, AgencyPhone, AgencyFax, AgencyMap " + " FROM Agencies "; SqlCommand command = new SqlCommand( query, connection); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Agency agency = new Agency(); agency.AgencyId = Convert.ToInt32(reader["AgencyId"]); agency.AgencyAddress = reader["AgencyAddress"].ToString(); agency.AgencyCity = reader["AgencyCity"].ToString(); agency.AgencyProv = reader["AgencyProv"].ToString(); agency.AgencyPostal = reader["AgencyPostal"].ToString(); agency.AgencyCountry = reader["AgencyCountry"].ToString(); agency.AgencyPhone = reader["AgencyPhone"].ToString(); agency.AgencyFax = reader["AgencyFax"].ToString(); agency.AgencyMap = reader["AgencyMap"].ToString(); agencies.Add(agency); } reader.Close(); } catch (SqlException ex) { throw ex; } finally { connection.Close(); } return agencies; }
public Agency Create(Agency Agency) { if (context.Agencies.Where(x => x.Identifier != null && x.Identifier == Agency.Identifier).Count() == 0) { Agency.Id = 0; Agency.Code = GetNewCodeValue(Agency.CompanyId ?? 0); Agency.Active = true; Agency.UpdatedAt = DateTime.Now; Agency.CreatedAt = DateTime.Now; context.Agencies.Add(Agency); return(Agency); } else { // Load remedy that will be updated Agency dbEntry = context.Agencies .FirstOrDefault(x => x.Identifier == Agency.Identifier && x.Active == true); if (dbEntry != null) { dbEntry.CountryId = Agency.CountryId ?? null; dbEntry.SectorId = Agency.SectorId ?? null; dbEntry.CompanyId = Agency.CompanyId ?? null; dbEntry.CreatedById = Agency.CreatedById ?? null; // Set properties dbEntry.Code = Agency.Code; dbEntry.Name = Agency.Name; // Set timestamp dbEntry.UpdatedAt = DateTime.Now; } return(dbEntry); } }
static void Main(string[] args) { List <Owner> owner = new List <Owner>(); List <Agency> agency = new List <Agency>(); List <Object1> object1 = new List <Object1>(); List <Lodger> lodger = new List <Lodger>(); FileStream file1 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Object.txt", FileMode.Create); FileStream file2 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Owner.txt", FileMode.Create); FileStream file3 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Agency.txt", FileMode.Create); FileStream file4 = new FileStream("C:\\Users\\79889\\source\\repos\\ConsoleApp3\\Files\\Lodger.txt", FileMode.Create); file1.Close(); file2.Close(); file3.Close(); file4.Close(); Object1.InputObject1(ref object1, ref owner); Owner.InputOwner(ref owner, ref object1, ref agency); Agency.InputAgency(ref agency, ref owner); Lodger.InputLodger(ref agency, ref owner); Console.ReadKey(); }
/// <summary> /// Returns true if BookingInfo instances are equal /// </summary> /// <param name="other">Instance of BookingInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(BookingInfo other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ContractId == other.ContractId || ContractId != null && ContractId.Equals(other.ContractId) ) && ( Agency == other.Agency || Agency.Equals(other.Agency) ) && ( Person == other.Person || Person != null && Person.Equals(other.Person) ) && ( Grade == other.Grade || Grade != null && Grade.Equals(other.Grade) ) && ( Rates == other.Rates || Rates != null && other.Rates != null && Rates.SequenceEqual(other.Rates) )); }
public ActionResult CreateClient(string Name, int Target_CPM, double Price) { if (Session["Data"] != null) { if ((Session["Data"] as SIGNINDATA).Type == "AGENCY") { int Agent_ID = (Session["Data"] as SIGNINDATA).ID; Agency agent = db.Agencies.Find(Agent_ID); Ads_Clients Ads_Client = new Ads_Clients { Name = Name, Target_CPM = Target_CPM, Price = Price, Agency_ID = agent.ID }; db.Ads_Clients.Add(Ads_Client); db.SaveChanges(); return(RedirectToAction("Index")); } } return(RedirectToAction("SignIn", "OGames")); }
private void AddAgencytoPayment(ComboBox para) { string query = "SELECT * FROM AGENCY WHERE ISDELETE = 0"; this.ListAgency = DataProvider.Instance.DB.Agencies.SqlQuery(query).ToList <Agency>(); if (String.IsNullOrEmpty(para.Text)) { MessageBox.Show("Vui lòng chọn đại lý"); } else { int pos = para.SelectedIndex; int id = ListAgency[pos].ID; Agency item = DataProvider.Instance.DB.Agencies.Where(x => x.ID == id).First(); this.HomeWindow.txbIDAgencyPayment.Text = item.ID.ToString(); this.HomeWindow.txbAgencyinPayment.Text = item.Name.ToString(); this.HomeWindow.txbAddressinPayment.Text = item.Address.ToString(); this.HomeWindow.txbPhoneNumberinPayment.Text = item.PhoneNumber.ToString(); } }
public ActionResult Edit([Bind(Include = "ID,Name,Target_CPM,Price,UserName,Password")] Agency agency, HttpPostedFileBase photo) { if (db.Third_Partner.Any(x => x.Password == agency.Password && x.User_Name == agency.UserName) || db.Channels.Any(x => x.Password == agency.Password && x.Username == agency.UserName) || db.Ads_Clients.Any(x => x.Password == agency.Password && x.UserName == agency.UserName) || db.Agencies.Any(x => x.UserName == agency.UserName && x.Password == agency.Password && x.ID != agency.ID)) { ViewBag.error = "This Username And Password Is Used !"; return(View(agency)); } if (ModelState.IsValid) { db.Entry(agency).State = EntityState.Modified; db.SaveChanges(); if (photo != null) { photo.SaveAs(Server.MapPath("~/Uploads/Agency/" + agency.ID + ".jpg")); } return(RedirectToAction("Index")); } return(View(agency)); }
private void LoadEntitiesFromDomain(long patientKey, long staffKey, long agencyKey, long locationKey) { Logger.Debug("LoadEntitiesFromDomain - Loading Entities"); var patientCriteria = DetachedCriteria.For <Patient> ("p").Add(Restrictions.Eq(Projections.Property("p.Key"), patientKey)); var staffCriteria = DetachedCriteria .For <Staff> ("s") .Add(Restrictions.Eq(Projections.Property("s.Key"), staffKey)); var agencyCriteria = DetachedCriteria.For <Agency> ("a").Add(Restrictions.Eq(Projections.Property("a.Key"), agencyKey)); var locationCriteria = DetachedCriteria.For <Location> ("l").Add(Restrictions.Eq(Projections.Property("l.Key"), locationKey)); var multiCriteria = _session.CreateMultiCriteria() .Add(patientCriteria) .Add(staffCriteria) .Add(agencyCriteria) .Add(locationCriteria); var criteriaList = multiCriteria.List(); try { _patient = (( IList )criteriaList[0])[0] as Patient; } catch (ArgumentOutOfRangeException) { //// No patient with an Id of [_patientKey] was found. _patient = null; } _staff = (( IList )criteriaList[1])[0] as Staff; _agency = (( IList )criteriaList[2])[0] as Agency; _location = (( IList )criteriaList[3])[0] as Location; }
/// <summary> /// Updates the agency /// </summary> /// <param name="agency">Agency</param> public virtual void UpdateAgency(Agency agency) { if (agency == null) { throw new ArgumentNullException(nameof(agency)); } if (agency is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } _agencyRepository.Update(agency); //cache _cacheManager.RemoveByPattern(ResearchAgencyDefaults.AgenciesPatternCacheKey); //_staticCacheManager.RemoveByPattern(ResearchAgencyDefaults.AgenciesPatternCacheKey); //event notification _eventPublisher.EntityUpdated(agency); }
void INewsManager.updateAgency(Agency agencyObj) { Console.WriteLine("{0}:{1}:{2}:{3}", DateTime.Now.Hour.ToString(), DateTime.Now.Minute.ToString(), DateTime.Now.Second.ToString(), DateTime.Now.Millisecond.ToString()); Console.WriteLine("NewsManager.updateAgency : editting Agency whose ID is: {0}", agencyObj.id); // update statement. string sql = "Update Agency set [City] = @city,[Language]=@language where [AgencyID]=@agencyID "; using (myCommand = new SqlCommand()) { myCommand = con.CreateCommand(); myCommand.CommandText = sql; // Create Parameter. myCommand.Parameters.Clear(); myCommand.Parameters.AddWithValue("@agencyID", agencyObj.id); myCommand.Parameters.AddWithValue("@city", agencyObj.city); myCommand.Parameters.AddWithValue("@language", agencyObj.language); myCommand.ExecuteNonQuery(); } }
private bool CheckData() { if (txtAgencyName.Text.Trim() == "") { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Chưa điền dữ liệu"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAgencyName.Focus(); return(false); } Agency agency = _agencyRepository.FirstOrDefault(_ => _.AgencyName.Equals(txtAgencyName.Text.Trim())); if (agency != null && ( String.IsNullOrEmpty(_id) || (!String.IsNullOrEmpty(_id) && txtAgencyName.Text.Trim() != agency.AgencyName) )) { XtraMessageBox.Show(LanguageTranslate.ChangeLanguageText("Dữ liệu đã tồn tại"), LanguageTranslate.ChangeLanguageText("Thông báo"), MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAgencyName.Focus(); return(false); } return(true); }
public ActionResult Edit(Agency model) { model.UpdatedAt = DateTime.Now; model.IsDeleted = false; if (ModelState.IsValid) { try { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(Content(javasctipt_add("/Agency", "Cập nhật dữ liệu thành công"))); } catch (Exception) { return(Content(javasctipt_add("/Agency", "Có lỗi xảy ra, vui lòng kiểm tra lại dữ liệu"))); } } var status = StatusUtils.GetSettingStatus(); ViewBag.IsActive = new SelectList(status, "Value", "Text", model.IsActive); return(Content(javasctipt_add("/Agency", "Cập nhật dữ liệu thất bại"))); }
public async Task ShouldFindSingleDirectionForRoute(string routeTag, string[] directions, string directionText) { #region SeedData var agency = new Agency { Tag = "TTC", Routes = new List <AgencyRoute>(), }; var route = new AgencyRoute { Agency = agency, Tag = routeTag, Directions = directions.Select(dTag => new RouteDirection { Tag = dTag.ToUpper(), Name = dTag.ToUpper(), }).ToList(), }; agency.Routes.Add(route); #endregion string[] results; using (BusVbotDbContext dbContext = DbContextProvider.CreateInMemoryDbContext(nameof(ShouldFindSingleDirectionForRoute))) { dbContext.Add(agency); dbContext.SaveChanges(); IAgencyDataParser sut = new TtcDataParser(dbContext); results = await sut.FindMatchingDirectionsForRouteAsync(routeTag, directionText); } Assert.Single(results); Assert.Single(directions, d => d.Equals(results[0], StringComparison.OrdinalIgnoreCase)); }
public IActionResult Edit(int id, Agency agency) { if (id != agency.Id) { return(NotFound()); } try { _agencyRepository.Update(agency); return(RedirectToAction("Index")); } catch (DbUpdateConcurrencyException) { ViewBag.Nationalities = _personRepository.Nationalities; ViewBag.AddressTypes = _personRepository.AddressTypes; ViewBag.PhoneTypes = _personRepository.PhoneTypes; ViewBag.EmailTypes = _personRepository.EmailTypes; ViewBag.SocialTypes = _personRepository.SocialTypes; ViewBag.OTTTypes = _personRepository.OTTTypes; ViewBag.BankAccountTypes = _personRepository.BankAccountTypes; ViewBag.BankCardTypes = _personRepository.BankCardTypes; ViewBag.Wards = _personRepository.Wards; ViewBag.DistrictPlaces = _personRepository.DistrictPlaces; ViewBag.Provinces = _personRepository.Provinces; ViewBag.Representatives = _personRepository.Representatives; ViewBag.Employees = _personRepository.Employees; ViewBag.AgencyGroups = _agencyRepository.AgencyGroups; ViewBag.AgencyBusinesses = _agencyRepository.AgencyBusinesses; ViewBag.CurrencyTypes = _agencyRepository.CurrencyTypes; ViewBag.PaymentTypes = _agencyRepository.PaymentTypes; ViewBag.PaymentTermTypes = _agencyRepository.PaymentTermTypes; ViewBag.AgencyDiscountTypes = _agencyRepository.AgencyDiscountTypes; ViewBag.PickupTypes = _agencyRepository.PickupTypes; ViewBag.AgencyDiscountCustomerTypes = _agencyRepository.AgencyDiscountCustomerTypes; return(View(agency)); } }
public void Count_Should_Work_Correct() { //Arrange var agency = new Agency(); var invoice = new Invoice("first", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 28), new DateTime(2001, 10, 28)); var invoice2 = new Invoice("second", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 28), new DateTime(2001, 10, 28)); var invoice3 = new Invoice("third", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 28), new DateTime(2001, 10, 28)); //Act agency.Create(invoice); agency.Create(invoice2); agency.Create(invoice3); var expectedCount = 3; var actualCount = agency.Count(); //Assert Assert.AreEqual(expectedCount, actualCount); }
public void SetUp() { _unitOfWorkAdmin = _factory.Create <IAdministrationUnitOfWork>(); _agency = AdministrationUnitTestFixture.AgencyDetails; _queryConfiguration = _agency.CreateQueryConfiguration(1, "QueryName2", false); _unitOfWorkAdmin.Setup(item => item.Find <Agency>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>())) .Returns(_agency); _unitOfWorkAdmin.Setup(item => item.Find <QueryConfiguration>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>())) .Returns(_queryConfiguration); SetUpQueryConfiguration(); _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>(); _identityProvider = new Mock <IServiceIdentityProvider>(); var identityContext = new IdentityContext { IdentityId = Guid.NewGuid() }; _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId); _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext); _queryCommandService = new Administration.Services.Command.QueryCommandService(_unitOfWorkAdmin.Object, Mock.Of <ILog>(), _authorizationPolicy.Object, _identityProvider.Object); }
public async Task <IActionResult> Approve(string agencyId) { Agency agency = await _context.GetAgency(agencyId); if (agency != null) { agency.ApprovalState = ApprovalState.Approved; agency.DateApproved = DateTime.UtcNow; agency.LastModified = DateTime.UtcNow; Assignment assignment = new Assignment() { AssignmentId = agencyId, Agency = agency, AgencyId = agency.AgencyId, IsDelegated = false }; _context.Add(assignment); await _context.SaveChangesAsync(); var creator = await _context.Users.FindAsync(agency.CreatorId); if (creator != null) { try { await SendApprovedEmail(creator, agencyId); } catch (Exception e) { } } return(RedirectToAction("Index", "Admin")); } return(Forbid()); }
public Agency GetAgencyByAttributes(Int32 idProfile, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes) { List <UserProfileAttribute> pAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(UserProfileAttribute)).Select(p => (UserProfileAttribute)p).ToList(); Dictionary <ProfileAttributeType, string> items = GetUserAttributesForAgency(provider, attributes); Agency agency = ProfileService.GetAgency(items); if (agency == null && provider.AutoAddAgency && items.Values.Where(v => String.IsNullOrEmpty(v)).Any()) { agency = ProfileService.SaveAgency(idProfile, items); } if (agency == null) { agency = ProfileService.GetDefaultAgency(idOrganization); } if (agency == null) { agency = ProfileService.GetEmptyAgencyForOrganization(idOrganization); } return(agency); }
public async Task <IEnumerable <Route> > GetRouteList(Agency agency, bool showDialogs = true) { var routes = new List <Route>(); //check if db has routes already routes = await _dbHelper.GetRoutesListAsync(agency); if (routes.Count == 0) { if (showDialogs) { UserDialogs.Instance.ShowLoading("Loading routes from net...", MaskType.Black); } var xml = await _client.GetStringAsync(EndPoints.RoutesUrl(agency.Tag)); var doc = XDoc.LoadXml(xml); foreach (var node in doc.GetDescendantElements("route")) { var route = new Route(); route.Tag = node.GetAttribute("tag"); route.Id = $"{agency.Id}.{route.Tag}"; route.ParentId = agency.Id; route.Title = node.GetAttribute("title"); route.AgencyTitle = agency.Title; routes.Add(route); route.AgencyTag = agency.Tag; _dbHelper.SaveRoute(route); //GetRouteDetails(route); } if (showDialogs) { UserDialogs.Instance.HideLoading(); } } return(routes); }
public AgencyResponse Delete(Guid identifier) { AgencyResponse response = new AgencyResponse(); try { Agency deletedAgency = unitOfWork.GetAgencyRepository().Delete(identifier); unitOfWork.Save(); response.Agency = deletedAgency.ConvertToAgencyViewModel(); response.Success = true; } catch (Exception ex) { response.Agency = new AgencyViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public ActionResult Edit(Agency model, HttpPostedFileBase img) { string s = ""; if (ModelState.IsValid) { if (img != null) { Guid g = Guid.NewGuid(); s = g + img.FileName; img.SaveAs(Server.MapPath("~/Images/Agency/" + s)); model.Image = s; } db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Dashboard")); } return(View(model)); }
/// <summary> /// Creates the patient. /// </summary> /// <param name="agency">The agency.</param> /// <param name="patientName">Name of the patient.</param> /// <param name="patientProfile">The patient profile.</param> /// <returns> /// A Patient. /// </returns> public Patient CreatePatient(Agency agency, PersonName patientName, PatientProfile patientProfile) { var newPatient = new Patient(agency, patientName, patientProfile); Patient createdPatient = null; DomainRuleEngine.CreateRuleEngine(newPatient, "CreatePatientRuleSet") .WithContext(newPatient.Profile) .Execute(() => { createdPatient = newPatient; newPatient.UpdateUniqueIdentifier(_patientUniqueIdentifierCalculator.GenerateUniqueIdentifier(newPatient)); _patientRepository.MakePersistent(newPatient); DomainEvent.Raise(new PatientCreatedEvent { Patient = newPatient }); }); return(createdPatient); }
protected void btnSave_Click(object sender, EventArgs e) { AgencyContact contact; if (Request.QueryString["contactid"] != null) { contact = Module.ContactGetById(Convert.ToInt32(Request.QueryString["contactid"])); } else { contact = new AgencyContact(); Agency agency = Module.AgencyGetById(Convert.ToInt32(Request.QueryString["agencyid"])); contact.Agency = agency; } contact.Name = txtName.Text; contact.Phone = txtPhone.Text; contact.Email = txtEmail.Text; contact.Position = txtPosition.Text; contact.IsBooker = chkBooker.Checked; contact.Note = txtNote.Text; try { if (!String.IsNullOrEmpty(txtBirthday.Text)) { contact.Birthday = DateTime.ParseExact(txtBirthday.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } else { contact.Birthday = null; } } catch (System.FormatException fe) { contact.Birthday = null; } Module.SaveOrUpdate(contact); Page.ClientScript.RegisterStartupScript(typeof(AgencyContactEdit), "close", "window.opener.location = window.opener.location; window.close();", true); }
[InlineData(43.6568934f, -79.435741f, 2)] // Dufferin Mall public async Task Should_Find_Multiple_Agencies_For_Location(float lat, float lon, int agencyMatches) { var agency1 = new Agency { Tag = "ttc", MaxLatitude = 43.90953, MinLatitude = 43.5918099, MinLongitude = -79.6499, MaxLongitude = -79.12305, }; var agency2 = new Agency { Tag = "other-agency", MaxLatitude = 43.90953, MinLatitude = 43.6479442, MinLongitude = -79.6499, MaxLongitude = -79.4015097, }; var location = new Location { Latitude = lat, Longitude = lon }; Agency[] agencies; using (var dbContext = DbContextProvider.CreateInMemoryDbContext(nameof(Should_Find_Multiple_Agencies_For_Location))) { dbContext.AddRange(agency1, agency2); dbContext.SaveChanges(); // ILocationsManager sut = new LocationsManager(null, dbContext); // agencies = await sut.FindAgenciesForLocationAsync(location); } // Assert.Equal(agencyMatches, agencies.Length); }
private object GetUrlAgency(Agency agency) { NameValueCollection nvcQueryString = new NameValueCollection(); nvcQueryString.Add("NodeId", "1"); nvcQueryString.Add("SectionId", "15"); if (!string.IsNullOrEmpty(txtTo.Text)) { nvcQueryString.Add("t", txtTo.Text); } if (agency != null) { nvcQueryString.Add("ai", agency.Id.ToString()); } nvcQueryString.Add("spay", "1"); var criterions = (from key in nvcQueryString.AllKeys from value in nvcQueryString.GetValues(key) select string.Format("{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(value))).ToArray(); return("?" + string.Join("&", criterions)); }
public void PayInvoice_Should_SetSubtotal_To_Zero() { //Arrange var agency = new Agency(); var invoice = new Invoice("first", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 12, 28), new DateTime(2001, 10, 28)); var invoice2 = new Invoice("second", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 11, 28), new DateTime(2001, 10, 28)); var invoice3 = new Invoice("third", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 20), new DateTime(2000, 10, 28)); //Act agency.Create(invoice); agency.Create(invoice2); agency.Create(invoice3); var expectedSubtotal = 0; agency.PayInvoice(new DateTime(2000, 10, 28)); //Assert Assert.AreEqual(expectedSubtotal, invoice3.Subtotal); }
/// <summary> /// Llena el grid de Agencies dependiendo de los filtros seleccionados /// </summary> /// <history> /// [emoguel] created 08/03/2016 /// </history> protected async void LoadAgencies(Agency agency = null) { try { status.Visibility = Visibility.Visible; int nIndex = 0; List <Agency> lstAgencies = await BRAgencies.GetAgencies(_agencyFilter, _nStatus); dtgAgencies.ItemsSource = lstAgencies; if (agency != null && lstAgencies.Count > 0) { agency = lstAgencies.FirstOrDefault(ag => ag.agID == agency.agID); nIndex = lstAgencies.IndexOf(agency); } GridHelper.SelectRow(dtgAgencies, nIndex); StatusBarReg.Content = lstAgencies.Count + " Agencies."; status.Visibility = Visibility.Collapsed; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
public void ThrowInvoice_Agency_Should_Not_Contain_Deleted_Invoice() { //Arrange var agency = new Agency(); var invoice = new Invoice("first", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 12, 28), new DateTime(2001, 10, 28)); var invoice2 = new Invoice("second", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 11, 28), new DateTime(2001, 10, 28)); var invoice3 = new Invoice("third", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 28), new DateTime(2001, 10, 28)); //Act agency.Create(invoice); agency.Create(invoice2); agency.Create(invoice3); agency.ThrowInvoice("first"); //Assert Assert.IsFalse(agency.Contains("first")); }
public JsonResult Delete(int id) { if (id == 0) { return(Json(new { responseCode = "-10" })); } Agency clase = db.Agencies.Find(id); clase.Enable = false; db.Entry(clase).State = EntityState.Modified; db.SaveChanges(); //Audito AuditHelper.Auditar("Baja", id.ToString(), "Agencia", ModuleDescription, WindowDescription); var responseObject = new { responseCode = 0 }; return(Json(responseObject)); }
public void SearchBySerialNumber_Should_Throw_Exception_With_Inalid_Number() { //Arrange var agency = new Agency(); var invoice = new Invoice("123", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 12, 28), new DateTime(2001, 10, 28)); var invoice2 = new Invoice("435", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 12, 29), new DateTime(2001, 10, 28)); var invoice3 = new Invoice("444", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 12, 30), new DateTime(2001, 10, 28)); var invoice4 = new Invoice("test3", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 10, 28), new DateTime(2001, 10, 28)); var invoice5 = new Invoice("test", "SoftUni", 1200, Department.Incomes, new DateTime(2000, 11, 28), new DateTime(2001, 10, 28)); //Act agency.Create(invoice); agency.Create(invoice2); agency.Create(invoice3); agency.Create(invoice4); agency.Create(invoice5); //Assert Assert.Throws <ArgumentException>(() => agency.SearchBySerialNumber("zssd")); }
// GET: /Agency/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Agency agency = await db.Agencies.FindAsync(id); if (agency == null) { return(HttpNotFound()); } ViewBag.CityId = agency.CityId; ViewBag.CountryId = agency.CountryId; ViewBag.StateId = agency.StateId; ViewBag.CustomerProfiles = db.CustomerProfiles; ViewBag.Destinations = db.Destinations; ViewBag.PaymentMethods = db.PaymentMethods; ViewBag.Products = db.Products; return(View(agency)); }
public void About() { Agency agency1 = new Agency { Name = "Agence 1", AdditionalInformation = "Description agence 1" }; Agency agency2 = new Agency { Name = "Agence 2", AdditionalInformation = "Description agence 2" }; Announcement announcement1 = new Announcement { Agency = agency1, Description = "Description de l'annonce 1", IsAvailable = true, Price = 400, Ref = "20151018.1", Surface = 100, Title = "Location Maison" }; Announcement announcement2 = new Announcement { Agency = agency1, Description = "Description de l'annonce 2", IsAvailable = true, Price = 160000, Ref = "20151018.2", Surface = 100, Title = "Venter Maison" }; ICollection<Agency> fakeAgencies = new List<Agency>(new[] { agency1, agency2 }); ICollection<Announcement> fakeAnnouncements = new List<Announcement>(new[] { announcement1, announcement2 }); IUnitOfWork fakeUnitOfWork = new FakeUnitOfWork(fakeAnnouncements, fakeAgencies); IAnnouncementService fakeAnnouncementService = new FakeAnnouncementService(); fakeAnnouncementService.UnitOfWork = fakeUnitOfWork; IAgencyService fakeAgencyService = new FakeAgencyService(); fakeAgencyService.UnitOfWork = fakeUnitOfWork; // Arrange HomeController controller = new HomeController(); controller.AnnouncementService = fakeAnnouncementService; controller.AgencyService = fakeAgencyService; // Act ViewResult result = controller.About() as ViewResult; // Assert Assert.AreEqual("Your application description page.", result.ViewBag.Message); Assert.AreEqual((result.Model as ICollection<Agency>).Count, 2); Assert.AreEqual(typeof(List<Agency>), result.Model.GetType()); Assert.AreEqual(typeof(List<Announcement>), result.ViewData["Announcements"].GetType()); }
public void Delete(Agency entity) { throw new NotImplementedException(); }
public void AddAgency(Agency agency) { UnitOfWork.Agencies.Add(agency); UnitOfWork.Commit(); }
public void UpdateAgency(Agency agency) { UnitOfWork.Agencies.Update(agency); UnitOfWork.Commit(); }
/// <summary> /// /// </summary> public void SaveAgency(Agency instance) { var tran = this.customPagedDAO.GetTransactionProvider(); try { tran.BeginTransaction(); this.customPagedDAO.MakePersistent(instance); tran.CommitTransaction(); } catch (Exception ex) { tran.RollbackTransaction(ex); } }
/// <summary> /// Assigns the patent agency. /// </summary> /// <param name="patentAgency"> /// The patent agency. /// </param> /// <returns> /// An AgencyBuilder. /// </returns> public AgencyBuilder WithPatentAgency(Agency patentAgency) { this._patentAgency = patentAgency; return this; }
public void Update(Agency dbAgency) { this.agencies.Update(dbAgency); this.agencies.SaveChanges(); }
public void Delete(Agency agencyFromDb) { this.agencies.Delete(agencyFromDb); }
private void insertDonorNmIfNotExist() { try { using (CCSEntities db = new CCSEntities()) { Agency ag = new Agency(); short donorRecordID = findAgencyRecord(); //checks if agency the exists already //add the new agency to the database, since it doesn't exist already if (donorRecordID == -1) { //FoodSource Table fields: Source, StoreID(Nullable), FoodSourceTypeID, and AddressID ag.AgencyName = txtAgencyName.Text; short addrRecordID = findAddrRecord(); //add the donor to the database if the able to lookup the address after the address was just inserted in if (addrRecordID != -1 && lblMessage.Text.Length == 0) { ag.AddressID = addrRecordID; //adds the AddressID to the FoodSource db.Agencies.Add(ag); //add the foodSource to the database db.SaveChanges(); LogChange.logChange("Agency " + ag.AgencyName + " was added.", DateTime.Now, short.Parse(Session["userID"].ToString())); } else { lblMessage.Text += "The agency was unable to be added.<br/>"; } } else { lblMessage.Text += txtAgencyName.Text + " agency with that address exists already!<br/>"; } } //end of using statement } catch (System.Threading.ThreadAbortException) { } catch (Exception ex) { LogError.logError(ex); Response.Redirect("../errorpages/error.aspx"); } }
public AgencyViewModel(Agency agency) { Agency = agency; TimeZone = agency.Tags.GetValue<TimeZoneInfo>("TimeZone", x => TimeZoneInfo.FindSystemTimeZoneById(x)); }
static void Main(string [] args) { Agency agency = new Agency(); Agent x = new Agent(); Agent y = new Agent(); Agent z = new Agent(); agency.onCall.addAgent(x); agency.onCall.addAgent(y); agency.onCall.addAgent(z); while (true) { agency.display(); foreach (Agent a in agency.onCall.agentList) { agency.field.agentList.Add(a); } foreach (Agent a in agency.field.agentList) { agency.onCall.agentList.Remove(a); } agency.turn(); Console.ReadLine(); } }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(Agency other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Tag, Tag); }
public AgencyEqualityTest() { _sut1 = new Agency(); _sut2 = new Agency(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) { id = int.Parse(Request.QueryString["id"]); using (CCSEntities db = new CCSEntities()) { ddlState.DataSource = db.States.ToList(); ddlState.DataBind(); a = (from ag in db.Agencies where ag.AgencyID == id select ag).First(); if(a != null){ txtAgencyName.Text = a.AgencyName; txtStreet1.Text = a.Address.StreetAddress1; txtStreet2.Text = a.Address.StreetAddress2; txtCity.Text = a.Address.City.CityName; txtZip.Text = a.Address.Zipcode.ZipCode1; ddlState.SelectedIndex = (int)a.Address.StateID; } } } } }