コード例 #1
0
		public void UpdateDeviceUser ( DeviceUser deviceUser ) {
			if ( deviceUser.Id == 0 ) {
				throw new ArgumentException ( "UpdateUser id==0" );
			}
			DeviceUsers.Attach ( deviceUser );
			Entry ( deviceUser ).State = EntityState.Modified;
		} 
コード例 #2
0
		public DbDataContextMock()
		{
			Advs =new List<Adv>();
			Companies = new List<Company>();
			DeviceUsers = new List<DeviceUser> ();
			Views = new List<AdvView>();
			CompanyUsers=new List<CompanyUser>();
			CompanyUserSessions = new List<CompanyUserSession>();
			var testAdv = new Adv () {
				Name = "apple" ,
				Link = "http://www.apple.com",
				Title = "Apple Inc.",
				Description = "empty description - apple",
				PhotoId = 1 ,
				DeviceUsers = new List<DeviceUser> ()
			};
			var testAdv1 = new Adv () {
				Name = "sony" ,
				Link = "http://sony.com" ,
				Title = "Sony" ,
				Description = "empty description - sony" ,
				PhotoId = 2 ,
				DeviceUsers = new List<DeviceUser> ()
			};
			var testUser = new DeviceUser () {
				DeviceId = "d1" ,
				Login = "******" ,
				Password = "******" ,
				Advs = new List<Adv> () ,
				Companies = new List<Company> ()
			};
			var testCompany = new Company () {
				ApiKey = "company1" ,
				Name = "company1" ,
				Advs = new List<Adv> () ,
				DeviceUsers = new List<DeviceUser> ()
			};
			var companyUser = new CompanyUser()
			{
				Login = "******",
				Company = testCompany,
				CompanyId = testCompany.Id,
				Password = AuthUtil.EncodePassword("admin")
			};


			testCompany.Advs.Add ( testAdv );
			testCompany.DeviceUsers.Add ( testUser );
			testCompany.Advs.Add(testAdv1);

			this.AddAdv ( testAdv );
			this.AddAdv(testAdv1);
			this.AddDeviceUser ( testUser );
			this.AddCompany ( testCompany );
			this.AddCompanyUser(companyUser);
		}
コード例 #3
0
		public AdvView RequestAdvertising(DeviceUser deviceUser, Company company, string ipAddress)
		{
			var adv = _dataContext.GetAdvs.OrderBy ( a => Guid.NewGuid () ).FirstOrDefault ();//todo: temp, need appy filter here
			if (adv == null) return null;

			var view = new AdvView
			{
				State = AdvViewState.New,
				Adv = adv,
				AdvId = adv.Id,
				UserId = deviceUser.Id,
				Time = DateTime.Now,
				IpAdress = ipAddress,
				CompanyId = company.Id,
			};
			_dataContext.AddView(view);
			_dataContext.SaveAll();
			return view;
		}
コード例 #4
0
		public void UpdateDeviceUser ( DeviceUser deviceUser )
		{
			var obj = DeviceUsers.First ( a => a.Id == deviceUser.Id );
			obj = deviceUser;
		}
コード例 #5
0
		public void AddDeviceUser ( DeviceUser deviceUser )
		{
			var maxUser = DeviceUsers.OrderByDescending ( a => a.Id ).FirstOrDefault ();
			deviceUser.Id = maxUser != null ? maxUser.Id + 1 : 1;
			DeviceUsers.Add ( deviceUser );
		}
コード例 #6
0
		public void AddDeviceUser ( DeviceUser deviceUser )
		{
			DeviceUsers.Add ( deviceUser );
		}