Example #1
0
        public bool UpdateGame(GameVM vm)
        {
            using (PlayContext context = new PlayContext())
            {
                try
                {
                    Game     game = context.Games.Single(x => x.ID == vm.Game.ID);
                    Location loc  = new Entities.Location();

                    game.Name        = vm.Game.Name;
                    game.Type        = vm.Game.Type;
                    game.Description = vm.Game.Description;
                    game.Start       = vm.Game.Start;
                    game.End         = vm.Game.End;
                    game.Modified    = DateTime.Now;

                    loc.Name        = vm.Game.Location.Name;
                    loc.Coordinates = CreatePoint(vm.Latitude, vm.Longitude);

                    game.Location = loc;

                    context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Example #2
0
        public void CreateLocation(string name, IEnumerable <ITradeable> resources)
        {
            var loc = new Entities.Location(name, resources);

            PexAssert.AreEqual(name, loc.Name);
            foreach (var tradeable in resources)
            {
                PexAssert.AreEqual(tradeable != null, loc.Resources.Contains(tradeable));
            }
        }
Example #3
0
 public Models.Location ParseLocation(Entities.Location location)
 {
     return(new Models.Location()
     {
         State = location.State,
         City = location.City,
         Street = location.Street,
         Id = location.Id
     });
 }
Example #4
0
        private void OnLocationBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
        {
            _currentLocation = uxLocationBindingSource.Current as Entities.Location;

            if (_currentLocation != null)
            {
                _currentLocation.Validate();
            }
            //_Location.Validate();
            OnCurrentEntityChanged();
        }
        private void CreateTestData()
        {
            validSwagRec    = new IO.Swagger.Models.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien");
            validSwagParcel = new IO.Swagger.Models.Parcel(1.5f, validSwagRec);
            validBLRec      = new Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien");
            validBLParcel   = new Entities.Parcel(1.5f, validBLRec);
            invalidBLRec    = new Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "1160", "Wien");
            invalidBLParcel = new Entities.Parcel(1.5f, invalidBLRec);
            validDALRec     = new DataAccess.Entities.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien");
            validDALParcel  = new DataAccess.Entities.Parcel(1.5f, validDALRec, 1);

            validSARecipient = new ServiceAgents.DTOs.Recipient("Tobias", "Test", "Horvathgasse 2", "A-1160", "Wien");
            validBLLocation  = new Entities.Location {
                Lat = 48.2057943, Lng = 16.3066716
            };
        }
Example #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (_entityState)
                {
                case EntityState.New:
                    new BusinessLayer.GenericService <Entities.Location>()
                    .Add(new Entities.Location {
                        Name = txtName.Text, Comment = txtComment.Text
                    });

                    break;

                case EntityState.Dirty:
                    Entities.Location location = new Entities.Location
                    {
                        Id      = LocationID,
                        Name    = txtName.Text,
                        Comment = txtComment.Text
                    };

                    new BusinessLayer.GenericService <Entities.Location>().Update(location, l => l.Id == location.Id);
                    break;

                default:
                    break;
                }

                Helper.ClearForm(this);
                btnSave.Text = "Save";
                _entityState = EntityState.New;
                Helper.ShowMessage("Location saved successfully", "Location Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);

                frmSetupDetails frmSetup = Helper.CreateInstanceFor <frmSetupDetails>("frmSetupDetails");
                if (frmSetup != null)
                {
                    frmSetup.LoadGridWithDataDatasource(() => new BusinessLayer.GenericService <Entities.Location>().GetAll());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An error occurred", "frmAddLocation", "btnSave");
                Helper.ShowMessage("Location was not saved successfully \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private Entities.Location CreateLocationAsync(LocationViewModel model)
        {
            var created = new Entities.Location
            {
                AreaCode    = model.AreaCode,
                City        = model.City,
                Country     = model.Country,
                Description = model.Description,
                Id          = (locations.Count + 1).ToString(),
                Line1       = model.Line1,
                Line2       = model.Line2,
                Name        = model.Name,
                Region      = model.Region
            };

            locations.Add(created);

            return(created);
        }
        /// <summary>
        /// Get All Locations with Location Type
        /// </summary>
        /// <returns>Will return a list of Location.</returns>
        public List <Entities.Location> GetAllLocationsWithLocationTypes()
        {
            var locations = new List <Entities.Location>();

            DbCommand dbCommand = null;

            try
            {
                using (dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetListOfAllLocationsWithLocationType))
                {
                    using (IDataReader reader = database.ExecuteReader(dbCommand))
                    {
                        while (reader.Read())
                        {
                            var location = new Entities.Location()
                            {
                                LocationId     = DRE.GetNullableInt32(reader, "location_id", null),
                                LocationName   = DRE.GetNullableString(reader, "location_name", null),
                                LocationTypeId = DRE.GetNullableInt32(reader, "location_type_id", null)
                            };

                            locations.Add(location);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbCommand = null;
            }

            return(locations);
        }
		private void OnLocationBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentLocation = uxLocationBindingSource.Current as Entities.Location;
			
			if (_currentLocation != null)
			{
				_currentLocation.Validate();
			}
			//_Location.Validate();
			OnCurrentEntityChanged();
		}
Example #10
0
        /// <summary>
        /// Initializes the component.
        /// </summary>
        public void InitializeComponent()
        {
            this.components      = new System.ComponentModel.Container();
            this.uxErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
            this.uxBindingSource = new System.Windows.Forms.BindingSource(this.components);

            //this.uxTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
            this.uxLocationId   = new System.Windows.Forms.TextBox();
            uxLocationIdLabel   = new System.Windows.Forms.Label();
            this.uxName         = new System.Windows.Forms.TextBox();
            uxNameLabel         = new System.Windows.Forms.Label();
            this.uxCostRate     = new System.Windows.Forms.TextBox();
            uxCostRateLabel     = new System.Windows.Forms.Label();
            this.uxAvailability = new System.Windows.Forms.TextBox();
            uxAvailabilityLabel = new System.Windows.Forms.Label();
            this.uxModifiedDate = new System.Windows.Forms.DateTimePicker();
            uxModifiedDateLabel = new System.Windows.Forms.Label();

            ((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).BeginInit();
            this.SuspendLayout();

            //
            // uxTableLayoutPanel
            //
            //this.uxTableLayoutPanel.AutoSize = true;
            //this.uxTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            //this.uxTableLayoutPanel.ColumnCount = 2;
            //this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F));
            //this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
            //this.uxTableLayoutPanel.Location = new System.Drawing.System.Drawing.Point(3, 3);
            //this.uxTableLayoutPanel.Name = "uxTableLayoutPanel";
            //this.uxTableLayoutPanel.RowCount = 2;
            //this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
            //this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
            //this.uxTableLayoutPanel.Size = new System.Drawing.Size(450, 50);
            //this.uxTableLayoutPanel.TabIndex = 0;

            //
            // uxErrorProvider
            //
            this.uxErrorProvider.ContainerControl = this;
            this.uxErrorProvider.DataSource       = this.uxBindingSource;

            //
            // uxLocationIdLabel
            //
            this.uxLocationIdLabel.Name     = "uxLocationIdLabel";
            this.uxLocationIdLabel.Text     = "Location Id:";
            this.uxLocationIdLabel.Location = new System.Drawing.Point(3, 0);
            this.Controls.Add(this.uxLocationIdLabel);
            //this.uxTableLayoutPanel.Controls.Add(this.uxLocationIdLabel);
            //
            // uxLocationId
            //
            this.uxLocationId.Name     = "uxLocationId";
            this.uxLocationId.ReadOnly = true;
            //this.uxTableLayoutPanel.Controls.Add(this.uxLocationId);
            this.uxLocationId.Location = new System.Drawing.Point(160, 0);
            this.Controls.Add(this.uxLocationId);
            //
            // uxNameLabel
            //
            this.uxNameLabel.Name     = "uxNameLabel";
            this.uxNameLabel.Text     = "Name:";
            this.uxNameLabel.Location = new System.Drawing.Point(3, 26);
            this.Controls.Add(this.uxNameLabel);
            //this.uxTableLayoutPanel.Controls.Add(this.uxNameLabel);
            //
            // uxName
            //
            this.uxName.Name      = "uxName";
            this.uxName.Width     = 250;
            this.uxName.MaxLength = 50;
            //this.uxTableLayoutPanel.Controls.Add(this.uxName);
            this.uxName.Location = new System.Drawing.Point(160, 26);
            this.Controls.Add(this.uxName);
            //
            // uxCostRateLabel
            //
            this.uxCostRateLabel.Name     = "uxCostRateLabel";
            this.uxCostRateLabel.Text     = "Cost Rate:";
            this.uxCostRateLabel.Location = new System.Drawing.Point(3, 52);
            this.Controls.Add(this.uxCostRateLabel);
            //this.uxTableLayoutPanel.Controls.Add(this.uxCostRateLabel);
            //
            // uxCostRate
            //
            this.uxCostRate.Name = "uxCostRate";
            //this.uxTableLayoutPanel.Controls.Add(this.uxCostRate);
            this.uxCostRate.Location = new System.Drawing.Point(160, 52);
            this.Controls.Add(this.uxCostRate);
            //
            // uxAvailabilityLabel
            //
            this.uxAvailabilityLabel.Name     = "uxAvailabilityLabel";
            this.uxAvailabilityLabel.Text     = "Availability:";
            this.uxAvailabilityLabel.Location = new System.Drawing.Point(3, 78);
            this.Controls.Add(this.uxAvailabilityLabel);
            //this.uxTableLayoutPanel.Controls.Add(this.uxAvailabilityLabel);
            //
            // uxAvailability
            //
            this.uxAvailability.Name = "uxAvailability";
            //this.uxTableLayoutPanel.Controls.Add(this.uxAvailability);
            this.uxAvailability.Location = new System.Drawing.Point(160, 78);
            this.Controls.Add(this.uxAvailability);
            //
            // uxModifiedDateLabel
            //
            this.uxModifiedDateLabel.Name     = "uxModifiedDateLabel";
            this.uxModifiedDateLabel.Text     = "Modified Date:";
            this.uxModifiedDateLabel.Location = new System.Drawing.Point(3, 104);
            this.Controls.Add(this.uxModifiedDateLabel);
            //this.uxTableLayoutPanel.Controls.Add(this.uxModifiedDateLabel);
            //
            // uxModifiedDate
            //
            this.uxModifiedDate.Name = "uxModifiedDate";
            //this.uxTableLayoutPanel.Controls.Add(this.uxModifiedDate);
            this.uxModifiedDate.Location = new System.Drawing.Point(160, 104);
            this.Controls.Add(this.uxModifiedDate);
            //
            // LocationEditControlBase
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            //this.Controls.Add(this.uxTableLayoutPanel);
            this.AutoScroll = true;
            this.Name       = "LocationEditControlBase";
            this.Size       = new System.Drawing.Size(478, 311);
            //this.Localizable = true;
            ((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
		/// <summary>
		/// Initializes the component.
		/// </summary>
		public void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.uxErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxBindingSource = new System.Windows.Forms.BindingSource(this.components);
			
			//this.uxTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
			this.uxLocationId = new System.Windows.Forms.TextBox();
			uxLocationIdLabel = new System.Windows.Forms.Label();
			this.uxName = new System.Windows.Forms.TextBox();
			uxNameLabel = new System.Windows.Forms.Label();
			this.uxCostRate = new System.Windows.Forms.TextBox();
			uxCostRateLabel = new System.Windows.Forms.Label();
			this.uxAvailability = new System.Windows.Forms.TextBox();
			uxAvailabilityLabel = new System.Windows.Forms.Label();
			this.uxModifiedDate = new System.Windows.Forms.DateTimePicker();
			uxModifiedDateLabel = new System.Windows.Forms.Label();
			
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).BeginInit();
			this.SuspendLayout();
			
			// 
			// uxTableLayoutPanel
			// 
			//this.uxTableLayoutPanel.AutoSize = true;
			//this.uxTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			//this.uxTableLayoutPanel.ColumnCount = 2;
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F));
			//this.uxTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 250F));
			//this.uxTableLayoutPanel.Location = new System.Drawing.System.Drawing.Point(3, 3);
			//this.uxTableLayoutPanel.Name = "uxTableLayoutPanel";
			//this.uxTableLayoutPanel.RowCount = 2;
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
			//this.uxTableLayoutPanel.Size = new System.Drawing.Size(450, 50);
			//this.uxTableLayoutPanel.TabIndex = 0;
			
			//
			// uxErrorProvider
			//
			this.uxErrorProvider.ContainerControl = this;
			this.uxErrorProvider.DataSource = this.uxBindingSource;
			
			//
			// uxLocationIdLabel
			//
			this.uxLocationIdLabel.Name = "uxLocationIdLabel";
			this.uxLocationIdLabel.Text = "Location Id:";
			this.uxLocationIdLabel.Location = new System.Drawing.Point(3, 0);
			this.Controls.Add(this.uxLocationIdLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxLocationIdLabel);			
			//
			// uxLocationId
			//
			this.uxLocationId.Name = "uxLocationId";
            this.uxLocationId.ReadOnly = true;
			//this.uxTableLayoutPanel.Controls.Add(this.uxLocationId);
			this.uxLocationId.Location = new System.Drawing.Point(160, 0);
			this.Controls.Add(this.uxLocationId);
			//
			// uxNameLabel
			//
			this.uxNameLabel.Name = "uxNameLabel";
			this.uxNameLabel.Text = "Name:";
			this.uxNameLabel.Location = new System.Drawing.Point(3, 26);
			this.Controls.Add(this.uxNameLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxNameLabel);			
			//
			// uxName
			//
			this.uxName.Name = "uxName";
			this.uxName.Width = 250;
			this.uxName.MaxLength = 50;
			//this.uxTableLayoutPanel.Controls.Add(this.uxName);
			this.uxName.Location = new System.Drawing.Point(160, 26);
			this.Controls.Add(this.uxName);
			//
			// uxCostRateLabel
			//
			this.uxCostRateLabel.Name = "uxCostRateLabel";
			this.uxCostRateLabel.Text = "Cost Rate:";
			this.uxCostRateLabel.Location = new System.Drawing.Point(3, 52);
			this.Controls.Add(this.uxCostRateLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxCostRateLabel);			
			//
			// uxCostRate
			//
			this.uxCostRate.Name = "uxCostRate";
			//this.uxTableLayoutPanel.Controls.Add(this.uxCostRate);
			this.uxCostRate.Location = new System.Drawing.Point(160, 52);
			this.Controls.Add(this.uxCostRate);
			//
			// uxAvailabilityLabel
			//
			this.uxAvailabilityLabel.Name = "uxAvailabilityLabel";
			this.uxAvailabilityLabel.Text = "Availability:";
			this.uxAvailabilityLabel.Location = new System.Drawing.Point(3, 78);
			this.Controls.Add(this.uxAvailabilityLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxAvailabilityLabel);			
			//
			// uxAvailability
			//
			this.uxAvailability.Name = "uxAvailability";
			//this.uxTableLayoutPanel.Controls.Add(this.uxAvailability);
			this.uxAvailability.Location = new System.Drawing.Point(160, 78);
			this.Controls.Add(this.uxAvailability);
			//
			// uxModifiedDateLabel
			//
			this.uxModifiedDateLabel.Name = "uxModifiedDateLabel";
			this.uxModifiedDateLabel.Text = "Modified Date:";
			this.uxModifiedDateLabel.Location = new System.Drawing.Point(3, 104);
			this.Controls.Add(this.uxModifiedDateLabel);
			//this.uxTableLayoutPanel.Controls.Add(this.uxModifiedDateLabel);			
			//
			// uxModifiedDate
			//
			this.uxModifiedDate.Name = "uxModifiedDate";
			//this.uxTableLayoutPanel.Controls.Add(this.uxModifiedDate);
			this.uxModifiedDate.Location = new System.Drawing.Point(160, 104);
			this.Controls.Add(this.uxModifiedDate);
			// 
			// LocationEditControlBase
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			//this.Controls.Add(this.uxTableLayoutPanel);
			this.AutoScroll = true;
			this.Name = "LocationEditControlBase";
			this.Size = new System.Drawing.Size(478, 311);
			//this.Localizable = true;
			((System.ComponentModel.ISupportInitialize)(this.uxErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxBindingSource)).EndInit();			
			this.ResumeLayout(false);
			this.PerformLayout();
		}
 public override void UpdateLocation(Entities.Location location)
 {
     _context.Entry(location).State = EntityState.Modified;
 }
 public override void InsertLocation(Entities.Location location)
 {
     _context.Location.Add(location);
 }
Example #14
0
        public void CreateMarket(string name, Entities.Location location)
        {
            var market = new Entities.Market(name);

            PexAssert.AreEqual(name, market.Name);
        }