public ActionResult Index(int idProduct = 0) { ViewBag.Sizes = repositorySizes.All(); ViewBag.Brands = repositoryBrands.All(); ViewBag.Categories = repositoryCategories.All(); if (idProduct != 0) { var product = new ViewModelProducts() { EntityProducts = repositoryProducts.FindBy(idProduct) }; product.CategoriesId = new int[product.EntityProducts.EntityProductsCategories.Count]; product.SizesId = new int[product.EntityProducts.EntityProductsSizes.Count]; for (var i = 0; i < product.EntityProducts.EntityProductsCategories.Count; i++) { product.CategoriesId[i] = product.EntityProducts.EntityProductsCategories[i].EntityCategories.IdCategory; } for (var i = 0; i < product.EntityProducts.EntityProductsSizes.Count; i++) { product.SizesId[i] = product.EntityProducts.EntityProductsSizes[i].EntitySizes.IdSize; } return(View(product)); } return(View()); }
public ActionResult Index() { var user = repositoryUsers.FindBy(field => field.IdLogin == User.Identity.GetUserId()).FirstOrDefault(); var cart = repositoryUsersProducts.FindBy(field => field.EntityUsers.IdUser == user.IdUser); return(View(cart)); }
protected User get_current_user() { string email = get_current_email(); IEnumerable <User> list = UserDB.FindBy(x => x.email == email); User user = list.Single(); return(user); }
public ActionResult Details(int id) { var model = new AdminBaseViewModel <JobApplication>(); var ob = _repo.FindBy(x => x.ID == id).FirstOrDefault(); model.Item = ob; SetListPage(Url.Action("Index", new { t = ob.Job.JobType.ToString().Replace("_", "").ToLowerInvariant(), s = ob.Status.ToString().ToLowerInvariant() })); return(View(model)); }
public List <Categoria> ObtenerPor(int idCategoriaRol) { using (var db = repo.ContextScope(new CmsContext())) { var tmp = idCategoriaRol == -1 ? repo.FindBy(x => x.idEmpresa == idEmpresa).ToList(): repo.FindBy(x => x.idEmpresa == idEmpresa && x.idCategoriaRol == idCategoriaRol).ToList(); return(tmp); } }
public void DeleteBooking(int bookingId) { Booking b = repos.FindBy <Booking>(book => book.Id == bookingId).FirstOrDefault(); repos.Remove <Booking>(b); repos.SaveChanges(); }
public ActionResult Sell(ViewModelProducts product) { var idlogin = User.Identity.GetUserId(); product.EntityProducts.EntityUsers = repositoryUsers.FindBy(field => field.IdLogin == User.Identity.GetUserId()).FirstOrDefault(); product.EntityProducts.Posted = DateTime.Now; product.EntityProducts.OnSale = false; foreach (var idCategory in product.CategoriesId) { var category = repositoryCategories.FindBy(idCategory); product.EntityProducts.EntityProductsCategories.Add(new ClassEntityProductsCategories { EntityCategories = category, EntityProducts = product.EntityProducts }); } foreach (var idSize in product.SizesId) { var Size = repositorySizes.FindBy(idSize); product.EntityProducts.EntityProductsSizes.Add(new ClassEntityProductsSizes { EntitySizes = Size, EntityProducts = product.EntityProducts }); } if (product.EntityProducts.IdProduct == 0) { repositoryProducts.Add(product.EntityProducts); } else { repositoryProducts.Update(product.EntityProducts); } var x = 1; string strpath = Server.MapPath("~/img/product/" + product.EntityProducts.IdProduct.ToString()); if (!(Directory.Exists(strpath))) { Directory.CreateDirectory(strpath); foreach (var file in product.EntityProducts.Files) { if (file != null) { var InputFileName = Path.GetFileName(x++.ToString() + "." + file.FileName.Split('.')[1]); var ServerSavePath = Path.Combine(strpath + "/" + InputFileName); //Save file to server folder file.SaveAs(ServerSavePath); } } } return(RedirectToAction("Products", "Seller")); }
public ActionResult Register() { var roles = repositoryRoles.FindBy(field => field.Name != "admin"); var _model = new RegisterViewModel { SelectedRole = "seller", Roles = new List <string>() }; ViewBag.Roles = roles; return(View(_model)); }
public void AuthorRepository_Searches_By_Author() { var result = _sut.FindBy(x => x.Author == "Mr Pressford").Single(); Assert.IsNotNull(result); Assert.AreEqual(result.Id, 1); }
public IHttpActionResult Get(int id) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } var user = Repository.FindBy <User>(u => u.Id == id) .Select(u => new { u.Id, Sso = u.Sso ? "1" : "0", u.Firstname, u.Lastname, u.Email, u.Disabled, u.Password, u.Username, u.LanguageId, u.ManagerId, u.Active, UserRights = u.UserRights.Select(p => new { p.RoleId }).ToList() }).SingleOrDefault(); if (user == null) { Log.MonitoringLogger.Warn("The UserId \"" + id + "\" is not found"); return(NotFound()); } return(Ok(user)); }
public void GetLongLineTrip([Values(15850)] int tripId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.Trip>(session); var source = repo.FindBy(tripId); Assert.NotNull(source); Assert.IsInstanceOf<Observer.Entities.LongLineTrip>(source); var destination = Mapper.Map<Observer.Entities.Trip, Tubs.Entities.Trip>(source) as Tubs.Entities.LongLineTrip; Assert.NotNull(destination); Assert.NotNull(destination.Gear); Assert.NotNull(destination.Electronics); Assert.AreEqual(30, destination.Electronics.Count); // select count(*) from l_sethaul where obstrip_id = 15850 // 9 entities Assert.NotNull(destination.FishingSets); Assert.AreEqual(9, destination.FishingSets.Count); var events = from fset in destination.FishingSets select fset.EventList.Count; Assert.AreEqual(96, events.Sum()); var setcatch = from fset in destination.FishingSets select fset.CatchList.Count; Assert.AreEqual(900, setcatch.Sum()); } }
public IHttpActionResult Authenticate([FromBody] string value) { // Check if the provided token exists in database var token = Repository.FindBy <Token>(t => t.Value == value) .Include(t => t.User.UserRights.Select(ugr => ugr.Roles)) .SingleOrDefault(); if (token == null || token.ExpirationDate < DateTime.Now) { // If the token doesn't exist, we return HTTP Response 401 Unauthorized return(Unauthorized()); } if (!token.User.Active) { // If the user isn't active, we return HTTP Response 403 Forbidden return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } // We return user's informations return(Ok(new { token.User.Username, token.User.Firstname, token.User.Lastname, token.User.LanguageId, Admin = token.User.UserRights.Any(r => r.RoleId == (int)Roles.Administrator), Token = new { token.UserId, token.Value, token.ExpirationDate } })); }
public async Task <IActionResult> Put(int id, T item) { if (id != item.Id) { return(BadRequest()); } await repo.UpdateAsync(item); try { await repo.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!repo.FindBy(a => a.Id == id).Any()) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void GetSetHaul([Values(63596, 63595, 62870, 60561, 59123, 50800)] int sethaulId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.LonglineFishingSet>(session); var src = repo.FindBy(sethaulId); Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.LonglineFishingSet, Tubs.Entities.LongLineSet>(src); Assert.NotNull(dest); Assert.NotNull(dest.NotesList); Assert.NotNull(dest.Baskets); Assert.NotNull(dest.EventList); Assert.True(dest.EventList.Count > 1); if (dest.LineSettingSpeedUnit.HasValue) { Assert.True(Tubs.Common.UnitOfMeasure.Knots.Equals(dest.LineSettingSpeedUnit.Value)); } if (!String.IsNullOrEmpty(dest.TargetSpeciesCode)) { StringAssert.AreEqualIgnoringCase("ALB", dest.TargetSpeciesCode); } Assert.True(dest.TotalHookCount.HasValue); Assert.AreEqual(1830, dest.TotalHookCount.Value); Assert.True(dest.TotalBasketCount.HasValue); Assert.AreEqual(61, dest.TotalBasketCount); Assert.True(dest.IsTargetingTuna.HasValue && dest.IsTargetingTuna.Value); } }
public ServiceResult <int> Upsert(AdminUserEntity model) { var response = ServiceResult <int> .Instance.ErrorResult(ServiceResultCode.Error); var otherNo = Repository.FindBy(x => x.Id != model.Id && x.Email == model.Email).Select(x => x.Id).FirstOrDefault(); if (otherNo > 0) { return(response.ErrorResult(ServiceResultCodeAdmin.DuplicateEmail)); } if (model.Id == 0) { var responseAdd = Add(model); if (!responseAdd.Success) { return(response.ErrorResult(responseAdd.Code)); } model = responseAdd.Value; } else { response = Edit(model); } return(response.SuccessResult(model.Id)); }
public async Task DrawWinner() { SetValue(() => WinnerName, string.Empty); var attendees = await Repository.FindBy <Attendee>(a => a.MeetingId == App.ActiveMeeting.MeetingId); // No one to pick then we are done if (attendees.Count == 0 || attendees.Count - _winners.Count == 0) { SetValue(() => WinnerName, "No more names to pick from"); return; } Attendee winner = null; while (winner == null) { Random rand = new Random(); int index = rand.Next(attendees.Count); winner = attendees[index]; if (_winners.Any(w => w.AttendeeId == winner.AttendeeId)) { winner = null; } } _winners.Add(winner); SetValue(() => WinnerName, $"The winner is: {winner.AttendeeName}"); }
private void btnSave_Click(object sender, EventArgs e) { // Sanity cecking. _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL")); Repository<Guid, APLBackendDB.Venue> _venueRepo = new Repository<Guid, APLBackendDB.Venue>(_unitOfWork.Session); Repository<Guid, APLBackendDB.Region> _regionRepo = new Repository<Guid, APLBackendDB.Region>(_unitOfWork.Session); _venue.Name = tbxVenueName.Text; _venue.Address1 = tbxAddr1.Text; _venue.Address2 = tbxAddr2.Text; _venue.Description = tbxDesc.Text; _venue.EmailAddress = tbxEmail.Text; _venue.Phone = tbxPhone.Text; int _pcode = 0; if (int.TryParse(tbxPcode.Text, out _pcode)) { _venue.Postcode = (short)_pcode; } Guid _regionId = Guid.Empty; if (Guid.TryParse(cbxRegion.SelectedValue.ToString(), out _regionId)) { _venue.Region = _regionRepo.FindBy(_regionId); _venue.State = _venue.Region.State; } _venue.Suburb = tbxSuburb.Text; _venue.Website = tbxURL.Text; if ( ! string.IsNullOrEmpty(tbxLat.Text) && ! String.IsNullOrEmpty(tbxLong.Text) ) { _venue.Lattitude = float.Parse(tbxLat.Text); _venue.Longitude = float.Parse(tbxLong.Text); } _venueRepo.AddOrUpdate(_venue); _unitOfWork.Commit(); }
public game getCurrentGame(string id) { int idL = int.Parse(id); var lanes = new Repository<lane>(); lane lane = lanes.FindBy(l => l.Id == idL).Single(); return lane.getCurrentGame(); }
public IHttpActionResult RecoverPassword([FromBody] string username) { var user = Repository.FindBy <User>(x => x.Username == username) .SingleOrDefault(); if (user == null) { var warningMessage = "The user \"" + username + "\" does not exist"; Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("username", warningMessage); return(BadRequest(ModelState)); } if (user.Sso) { var warningMessage = "The user \"" + user.Username + "\" is an SSO user"; Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("username", warningMessage); return(BadRequest(ModelState)); } if (!user.Active) { var warningMessage = "The user \"" + user.Username + "\" is disabled"; Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("username", warningMessage); return(BadRequest(ModelState)); } UpsertToken(user); SendChangePasswordEmail(user); var message = "A password recovery email has been sent to the user \"" + username + "\""; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public IHttpActionResult Delete(int id) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } var user = Repository.FindBy <User>(w => w.Id == id).SingleOrDefault(); if (user == null) { return(NotFound()); } var token = Repository.FindBy <Token>(t => t.UserId == user.Id).SingleOrDefault(); if (token != null) { Repository.Delete(token); } foreach (UserRights ur in user.UserRights.ToList()) { Repository.Delete(ur); } Repository.Delete(user); Repository.Save(); var message = "The user \"" + user.Username + "\" has been deleted"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public IHttpActionResult put([FromBody] Organization org) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } if (Repository.FindBy <Organization>(u => u.ShortName == org.ShortName && u.Id != org.Id && u.ParentId != org.ParentId).Any()) { var warningMessage = "The Organization Name \"" + org.ShortName + "\" already exists"; // Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("org.name", warningMessage); return(BadRequest(ModelState)); } org.ModifiedBy = principal.Id; org.ModifiedDate = System.DateTime.Now; Repository.Update(org); Repository.Save(); var message = "The Organization \"" + org.ShortName + "\" has been updated"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public player find(string id) { int idP = int.Parse(id); Repository<player> players = new Repository<player>(); return players.FindBy(g => g.Id == idP).FirstOrDefault(); }
public IHttpActionResult Post([FromBody] LookupTables lookupTable) { if (Repository.FindBy <LookupTables>(lt => lt.TableName == lookupTable.TableName).Any()) { var warningMessage = "The Table \"" + lookupTable.TableName + "\" already exists"; // Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("alreadyExists", warningMessage); return(BadRequest(ModelState)); } StringBuilder sb = new StringBuilder(); sb.Append("CREATE TABLE [dbo].[lk_" + lookupTable.TableName + "]( Id INT IDENTITY PRIMARY KEY,"); foreach (LookUpColumns col in lookupTable.Columns) { string datatype = col.DataType.Contains("char") ? col.DataType + "(" + col.length + ")" : col.DataType; string unique = col.Unique ? "UNIQUE" : ""; sb.Append(col.ColumnName + " " + datatype + " " + unique + " ,"); } sb.Append(")"); var table = Repository.Context.Database.ExecuteSqlCommand(sb.ToString(), new SqlParameter("@tableName", lookupTable.TableName)); Repository.Add(lookupTable); Repository.Save(); var message = "The Table \"" + lookupTable.TableName + "\" has been Created"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public IHttpActionResult Get(int id) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } var role = Repository.FindBy <Role>(r => r.Id == id) .Select(r => new { r.Id, r.Name, r.Description, UserRights = r.UserRights.Select(p => new { p.UserId }).ToList() }).SingleOrDefault(); if (role == null) { Log.MonitoringLogger.Warn("The Role \"" + id + "\" is not found"); return(NotFound()); } return(Ok(role)); }
public IHttpActionResult Delete(int id) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } var attrgroup = Repository.FindBy <AttributeGroup>(w => w.Id == id).SingleOrDefault(); if (attrgroup == null) { return(NotFound()); } var attrList = Repository.GetAll <Data.MasterData.Attribute>().Where(a => a.AttributeGroupId == id).ToList(); foreach (Data.MasterData.Attribute attr in attrList) { Repository.Delete(attr); } Repository.Delete(attrgroup); Repository.Save(); var message = "The Attribute Group \"" + attrgroup.ShortName + "\" has been deleted"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public IHttpActionResult Post([FromBody] ImportProfile profile) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } if (Repository.FindBy <ImportProfile>(p => p.Name == profile.Name).Any()) { var warningMessage = "The ProfileName \"" + profile.Name + "\" already exists"; // Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("alreadyExists", warningMessage); return(BadRequest(ModelState)); } profile.CreatedBy = principal.Username; profile.CreatedDate = DateTime.Now; Repository.Add(profile); Repository.Save(); var message = "The Profile \"" + profile.Name + "\" has been added"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public CsdnCrawler() { tagManager = new Repository <Fry_Tag>(); articleManager = new Repository <Fry_Article>(); //获取所有国家电网板块 fryTags = tagManager.FindBy(r => r.Id > 0); }
public Task <T> FindByTest <T>([PexAssumeNotNull] Repository <T> target, Expression <Func <T, bool> > predicate) where T : class, new() { Task <T> result = target.FindBy(predicate); return(result); }
public override async Task <ActionResult <IEnumerable <Tutorial> > > Get(string login, bool?onlyActive = null) { List <Tutorial> list = new List <Tutorial>(); Expression <Func <Tutorial, bool> > predicate; if (onlyActive == true && login == null) { predicate = a => a.Active == true; } else if (onlyActive != true && login != null) { predicate = a => a.Login == login; } else if (onlyActive == true && login != null) { predicate = a => a.Active == true && a.Login == login; } else { list = await repo.GetListAsync(); list.ForEach(a => a.Content = null); return(list); } list = await repo.FindBy(predicate).ToListAsync(); list.ForEach(a => a.Content = null); return(list); }
public bool isAvalaible(string id) { int idL = int.Parse(id); var lanes = new Repository<lane>(); lane lane = lanes.FindBy(l => l.Id == idL).Single(); return lane.isAvalaible(); }
public IHttpActionResult Post([FromBody] User user) { var principal = (User)User.Identity; if (!principal.UserRights.Any(ur => ur.RoleId == (int)Roles.Administrator)) { return(new StatusCodeResult(HttpStatusCode.Forbidden, Request)); } user.Active = true; user.Password = PasswordManagerProvider.Hash(user.Password); if (Repository.FindBy <User>(u => u.Username == user.Username).Any()) { var warningMessage = "The username \"" + user.Username + "\" already exists"; // Log.MonitoringLogger.Warn(warningMessage); ModelState.AddModelError("user.login", warningMessage); return(BadRequest(ModelState)); } Repository.Add(user); Repository.Save(); var message = user.Id; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public void AuthorRepository_Searches_By_Author() { var result = _sut.FindBy(x => x.Email == "*****@*****.**").Single(); Assert.IsNotNull(result); Assert.AreEqual(result.Id, 1); }
public ActionResult Details(int id) { var model = new AdminBaseViewModel <Contact>(); model.Item = _repo.FindBy(x => x.ID == id).FirstOrDefault(); return(View(model)); }
public async Task RefreshAttendees() { var attendees = await Repository.FindBy <Attendee>(a => a.MeetingId == _meeting.MeetingId); attendees = attendees.OrderBy(a => a.AttendeeName).ToList(); SetValue(() => Attendees, attendees); }
public IEnumerable <TEntity> GetByProperty(string propertyName, object value) { using (var context = CreateContext(ConnectionString)) { var repo = new Repository <TEntity>(context); return(repo.FindBy(propertyName, value)); } }
public void GetByStaffCode([Values("DJB")] string staffCode) { var repo = new Repository<FieldStaff>(DataService.GetSession()); var person = repo.FindBy(staffCode); Assert.NotNull(person); StringAssert.AreEqualIgnoringCase(staffCode, person.StaffCode); Assert.AreEqual("DAVE J", person.FirstName); Assert.IsTrue("Dave J".Equals(person.FirstName.Trim(), StringComparison.CurrentCultureIgnoreCase)); }
public IHttpActionResult Delete(int tableId, int id) { var tableDetails = Repository.FindBy <LookupTables>(lt => lt.Id == tableId).SingleOrDefault(); var table = Repository.Context.Database.ExecuteSqlCommand(de.DeleteQuery(tableDetails.TableName, id), new SqlParameter("@tableName", tableDetails.TableName)); var message = "Record has been deleted"; Log.MonitoringLogger.Info(message); return(Ok(message)); }
public void GetSeaDay() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsDay>(session); var src = repo.FindBy(12345); Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PsDay, Tubs.Entities.PurseSeineSeaDay>(src); Assert.NotNull(dest); } }
public NewsItemEdit(Guid newsItemId) { this.ShowInTaskbar = false; AllowDrop = true; _newsItemId = newsItemId; _sessionHelper = new SessionHelper(); Repository<Guid, NewsItem> _newsItemRepo = new Repository<Guid, NewsItem>(_sessionHelper.GetSession("APL")); _newsItem = _newsItemRepo.FindBy(_newsItemId); InitializeComponent(); PopulateForm(); }
public void GetKiobTrip([Values(3900)] int tripId) { using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.Trip>(session); var source = repo.FindBy(tripId); Assert.NotNull(source); Assert.IsInstanceOf<Observer.Entities.PurseSeineTrip>(source); var destination = Mapper.Map<Observer.Entities.Trip, Tubs.Entities.Trip>(source) as Tubs.Entities.PurseSeineTrip; Assert.NotNull(destination); } }
private System.Threading.Tasks.Task DoSync() { System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(() => { DataLayer.SessionHelper _sessionHelper = new SessionHelper(); UnitOfWork _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL")); Repository<Guid, Setting> _settingRepo = new Repository<Guid, APLBackendDB.Setting>(_unitOfWork.Session); Setting _settings = new Setting(); SetStatusText("Starting sync..."); Util.DBSync d = new Util.DBSync(); d.ProgressUpdate += D_ProgressUpdate; SetStatusText("Syncing States..."); d.SyncState(); SetStatusText("Syncing Brands..."); d.SyncBrand(); SetStatusText("Syncing Regions..."); d.SyncRegion(); SetStatusText("Syncing Venues..."); d.SyncVenue(); SetStatusText("Syncing Game Types..."); d.SyncGameType(); SetStatusText("Syncing Games..."); d.SyncGame(); SetStatusText("Syncing Customers..."); d.SyncCustomer(); SetStatusText("Sync Completed."); btSync.Enabled = true; Setting lastSync = _settingRepo.FindBy(p => (p.Keyname == "LastCompleteSync")); if (lastSync == null || string.IsNullOrEmpty(lastSync.Value)) { lastSync = new Setting(); lastSync.Keyname = "LastCompleteSync"; } lastSync.Value = DateTime.Now.ToString(); _settingRepo.AddOrUpdate(lastSync); _unitOfWork.Commit(); }); t.Start(); return t; }
public void GetVesselNotes() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.Trip>(session); var source = repo.FindBy(572); Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.Trip, Tubs.Entities.VesselNotes>(source); Assert.NotNull(destination); StringAssert.AreEqualIgnoringCase("PNG-PH-524", destination.Licenses); } }
public void GetVesselAttributes() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsVesselAttributes>(session); var src = repo.FindBy(2212); // obstrip_id 15735 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PsVesselAttributes, Tubs.Entities.PurseSeineVesselAttributes>(src); Assert.NotNull(dest); } }
public void GetPollutionEvent() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PollutionHeader>(session); var src = repo.FindBy(2588); // From obstrip_id 15013 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PollutionHeader, Tubs.Entities.PollutionEvent>(src); Assert.NotNull(dest); Assert.NotNull(dest.Details); } }
public void GetMarineDevice() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.MarineDevice>(session); var source = repo.FindBy(72); Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.MarineDevice, Tubs.Entities.MarineDevice>(source); Assert.NotNull(destination); StringAssert.AreEqualIgnoringCase("WIND SPEED/DIRECTION GAUGE", destination.Description); StringAssert.AreEqualIgnoringCase("Wind Speed / Direction Gauge", destination.Category); } }
public void GetCrew([Values(455)] int crewId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsCrewMember>(session); var source = repo.FindBy(crewId); Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.PsCrewMember, Tubs.Entities.PurseSeineCrew>(source); Assert.NotNull(destination); StringAssert.AreEqualIgnoringCase("Wen Te Lang", destination.Name); StringAssert.AreEqualIgnoringCase("TW", destination.CountryCode); Assert.True(destination.Job.HasValue); Assert.AreEqual(Tubs.Common.JobType.DeckBoss, destination.Job.Value); } }
public void GetElectronicDevice([Values(31820)] int electronicsId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.Electronics>(session); var source = repo.FindBy(electronicsId); // From obstrip_id 7175 Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.Electronics, Tubs.Entities.ElectronicDevice>(source); Assert.NotNull(destination); Assert.NotNull(destination.DeviceType); StringAssert.AreEqualIgnoringCase("KODEN", destination.Make); StringAssert.AreEqualIgnoringCase("KGP-913", destination.Model); Assert.True(destination.Usage.HasValue); Assert.AreEqual(Tubs.Common.UsageCode.ALL, destination.Usage.Value); } }
public void GetInteraction([Values(3915)] int interactionId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.SsInteraction>(session); var src = repo.FindBy(interactionId); // obstrip_id 15112 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.SsInteraction, Tubs.Entities.SpecialSpeciesInteraction>(src); Assert.NotNull(dest); StringAssert.AreEqualIgnoringCase("S", dest.SgType); StringAssert.AreEqualIgnoringCase("RTD", dest.SpeciesCode); StringAssert.AreEqualIgnoringCase("0817", dest.LandedTimeOnly); Assert.True(dest.LandedDate.HasValue); } }
public void GetPurseSeineGear([Values(2198)] int gearId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsFishingGear>(session); var source = repo.FindBy(gearId); // obstrip_id 15736 Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.PsFishingGear, Tubs.Entities.PurseSeineGear>(source); Assert.NotNull(destination); StringAssert.AreEqualIgnoringCase("MARINE HYDROTEC", destination.PowerblockModel); StringAssert.AreEqualIgnoringCase("MARCO WS454", destination.PurseWinchModel); Assert.AreEqual(240, destination.NetDepth); Assert.True(destination.NetDepthUnit.HasValue); Assert.AreEqual(Tubs.Common.UnitOfMeasure.Meters, destination.NetDepthUnit.Value); } }
public void GetLengthSample() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsLengthFrequencyHeader>(session); var source = repo.FindBy(66000); Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.PsLengthFrequencyHeader, Tubs.Entities.LengthSamplingHeader>(source); Assert.NotNull(destination); Assert.NotNull(destination.Samples); Assert.AreEqual(21.0, destination.SumOfAllBrails); Assert.AreEqual(30, destination.TotalBrailCount); Assert.AreEqual(11, destination.SevenEighthsBrailCount); Assert.AreEqual(7, destination.ThreeQuartersBrailCount); } }
public void GetWellContent() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsWellContent>(session); var src = repo.FindBy(1600); // obstrip_id 14938 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PsWellContent, Tubs.Entities.PurseSeineWellContent>(src); Assert.NotNull(dest); Assert.True(dest.FuelOrWater.HasValue); Assert.AreEqual(Tubs.Common.WellContentType.Water, dest.FuelOrWater.Value); Assert.True(dest.WellNumber.HasValue); Assert.AreEqual(3, dest.WellNumber.Value); Assert.True(dest.WellCapacity.HasValue); Assert.AreEqual(45.0, dest.WellCapacity.Value); } }
public void GetGen3() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.Gen3Form>(session); var src = repo.FindBy(1514); // obstrip_id 15119 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.Gen3Form, Tubs.Entities.TripMonitor>(src); Assert.NotNull(dest); Assert.True(dest.Question5.HasValue); Assert.True(dest.Question5.Value); Assert.True(dest.Question4.HasValue); Assert.False(dest.Question4.Value); Assert.NotNull(dest.Details); Assert.True(dest.Details.Count > 0); } }
public void GetLongLineCatch([Values(2515256, 2515246, 2515266, 2515258)] int catchId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.LonglineCatch>(session); var src = repo.FindBy(catchId); Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.LonglineCatch, Tubs.Entities.LongLineCatch>(src); Assert.NotNull(dest); Assert.IsNotNullOrEmpty(dest.SpeciesCode); Assert.AreEqual(Tubs.Common.ConditionCode.A1, dest.LandedConditionCode); Assert.AreEqual(Tubs.Common.SexCode.F, dest.SexCode); var xmas = new System.DateTime(2011, 12, 25); Assert.AreEqual(xmas, dest.DateOnly); Assert.IsNotNullOrEmpty(dest.TimeOnly); } }
public void GetLongLineGear([Values(1370)] int gearId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.LonglineFishingGear>(session); var source = repo.FindBy(gearId); // obstrip_id 14895 Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.LonglineFishingGear, Tubs.Entities.LongLineGear>(source); Assert.NotNull(destination); Assert.True(destination.HasMainlineHauler.HasValue && destination.HasMainlineHauler.Value); Assert.True(UsageCode.ALL.Equals(destination.MainlineHaulerUsage)); Assert.True(destination.HasBranchlineHauler.HasValue); Assert.False(destination.HasBranchlineHauler.Value); StringAssert.AreEqualIgnoringCase("MONOFILAMENT", destination.MainlineMaterial); Assert.True(destination.MainlineLength.HasValue); Assert.AreEqual(38, destination.MainlineLength.Value); } }
public void GetSafetyInspection() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.SafetyInspection>(session); var src = repo.FindBy(1635); // obstrip_id 15118 Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.SafetyInspection, Tubs.Entities.SafetyInspection>(src); Assert.NotNull(dest); Assert.True(dest.LifejacketProvided.HasValue); Assert.True(dest.LifejacketProvided.Value); Assert.True(dest.LifejacketSizeOk.HasValue); Assert.True(dest.LifejacketSizeOk.Value); StringAssert.AreEqualIgnoringCase("E", dest.LifejacketAvailability); Assert.NotNull(dest.Epirb1); StringAssert.AreEqualIgnoringCase("406", dest.Epirb1.BeaconType); } }
public void GetActivity([Values(623024)] int activityId) { Mapper.AssertConfigurationIsValid(); Console.WriteLine("Valid configuration..."); using (var session = Observer.DataService.GetSession()) { Console.WriteLine("Opened session"); Assert.IsTrue(session.IsOpen); Console.WriteLine("Session is open"); var repo = new Repository<Observer.Entities.PsDailyEvent>(session); Console.WriteLine("Created PsDailyEvent repository"); var source = repo.FindBy(activityId); // From obstrip_id 11746 Console.WriteLine("Checking if returned entity is null"); Assert.NotNull(source); Console.WriteLine("Source entity not null, mapping with AutoMapper"); var destination = Mapper.Map<Observer.Entities.PsDailyEvent, Tubs.Entities.PurseSeineActivity>(source); Assert.NotNull(destination); // TODO Pick some fields to check } }
public void GetWellReconciliation() { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsWellReconciliation>(session); var src = repo.FindBy(13526); Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PsWellReconciliation, Tubs.Entities.PurseSeineWellReconciliation>(src); Assert.NotNull(dest); Assert.True(dest.LogsheetDate.HasValue); StringAssert.AreEqualIgnoringCase("0215", dest.LogsheetTimeOnly); Assert.True(dest.ObserverDate.HasValue); StringAssert.AreEqualIgnoringCase("0214", dest.ObserverTimeOnly); Assert.True(dest.PortWell5.HasValue); Assert.AreEqual(28.0, dest.PortWell5.Value); Assert.True(dest.StarboardWell3.HasValue); Assert.AreEqual(37.0, dest.StarboardWell3.Value); } }
public void GetSet([Values(1116394)] int setId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.PsFishingSet>(session); var src = repo.FindBy(setId); Assert.NotNull(src); var dest = Mapper.Map<Observer.Entities.PsFishingSet, Tubs.Entities.PurseSeineSet>(src); Assert.NotNull(dest); Assert.NotNull(dest.SamplingHeaders); Assert.True(dest.SamplingHeaders.Count > 1); foreach (var header in dest.SamplingHeaders) { Assert.NotNull(header); StringAssert.AreEqualIgnoringCase("alberts", header.EnteredBy); StringAssert.AreEqualIgnoringCase("T", header.MeasuringInstrument); } } }
public void GetTransfer() { Mapper.AssertConfigurationIsValid(); Console.WriteLine("Valid configuration..."); using (var session = Observer.DataService.GetSession()) { Console.WriteLine("Opened session"); Assert.IsTrue(session.IsOpen); Console.WriteLine("Session is open"); var repo = new Repository<Observer.Entities.FishTransfer>(session); Console.WriteLine("Created FishTransfer repository"); var source = repo.FindBy(51); // From obstrip_id 8450 Console.WriteLine("Checking if returned entity is null"); Assert.NotNull(source); Console.WriteLine("Source entity not null, mapping with AutoMapper"); var destination = Mapper.Map<Observer.Entities.FishTransfer, Tubs.Entities.Transfer>(source); Assert.NotNull(destination); // TODO Pick some fields to check } }
public void GetConversionFactors([Values(228618, 228620, 228621)] int factorId) { Mapper.AssertConfigurationIsValid(); using (var session = Observer.DataService.GetSession()) { var repo = new Repository<Observer.Entities.LonglineConversionFactor>(session); var source = repo.FindBy(factorId); // obstrip_id 10221 Assert.NotNull(source); var destination = Mapper.Map<Observer.Entities.LonglineConversionFactor, Tubs.Entities.LongLineConversionFactor>(source); Assert.NotNull(destination); StringAssert.AreEqualIgnoringCase("swo", destination.SpeciesCode); Assert.True(destination.UfLength.HasValue); Assert.AreEqual(0, destination.UfLength.Value); Assert.IsNotNullOrEmpty(destination.ProcessedWeightCode); Assert.True( "GH".Equals(destination.ProcessedWeightCode, StringComparison.InvariantCultureIgnoreCase) || "NM".Equals(destination.ProcessedWeightCode, StringComparison.InvariantCultureIgnoreCase)); Assert.True(destination.LfLength.HasValue); Assert.True(destination.LfLength.Value > 75); } }