public AdvModel(AdvView advView,double longitude,double latitude) { var adv = advView.Adv; AdvViewId = advView.Id; Id = adv.Id; Name = adv.Name; Longitude = adv.Longitude; Latitude = adv.Latitude; PhotoId = adv.PhotoId; Distance = Math.Sqrt(Math.Pow(Math.Abs(longitude - Longitude), 2) + Math.Pow(Math.Abs(latitude - Latitude), 2)); Title = adv.Title; Description = adv.Description; Link = adv.Link; }
public AdvModel ( AdvView advView ) { var adv = advView.Adv; AdvViewId = advView.Id; Id = adv.Id; Name = adv.Name; Longitude = adv.Longitude; Latitude = adv.Latitude; PhotoId = adv.PhotoId; Distance = -1; Title = adv.Title; Description = adv.Description; Link = adv.Link; }
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 UpdateView ( AdvView view ) { var obj = Views.First ( a => a.Id == view.Id ); obj = view; }
public void AddView ( AdvView view ) { var maxView = Views.OrderByDescending( a => a.Id ).FirstOrDefault (); view.Id = maxView != null ? maxView.Id + 1 : 1; Views.Add ( view ); }
public void UpdateView ( AdvView view ) { if ( view.Id == 0 ) { throw new ArgumentException ( "UpdateView id==0" ); } Views.Attach ( view ); Entry ( view ).State = EntityState.Modified; }
public void AddView ( AdvView view ) { Views.Add(view); }
public void ConfirmAdvertisingShowed(AdvView view) { //view.IsViewed = true; todo _dataContext.UpdateView(view); }