public void UpdateDeviceUser ( DeviceUser deviceUser ) { if ( deviceUser.Id == 0 ) { throw new ArgumentException ( "UpdateUser id==0" ); } DeviceUsers.Attach ( deviceUser ); Entry ( deviceUser ).State = EntityState.Modified; }
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); }
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; }
public void UpdateDeviceUser ( DeviceUser deviceUser ) { var obj = DeviceUsers.First ( a => a.Id == deviceUser.Id ); obj = deviceUser; }
public void AddDeviceUser ( DeviceUser deviceUser ) { var maxUser = DeviceUsers.OrderByDescending ( a => a.Id ).FirstOrDefault (); deviceUser.Id = maxUser != null ? maxUser.Id + 1 : 1; DeviceUsers.Add ( deviceUser ); }
public void AddDeviceUser ( DeviceUser deviceUser ) { DeviceUsers.Add ( deviceUser ); }