public BioService.Visitor Update(BioService.Visitor proto) { if (proto.Photo != null) { proto.Photo.FileLocation = _utils.GetLocationImagePath(proto.Locationid); if (proto.Photo.Fir != null && proto.Photo.Fir.Length > 0) proto.Photo.FirLocation = _utils.GetLocationFirPath(proto.Locationid); } BioService.Photo updatedPhoto = _photos.UpdateFromProto(proto.Photo); if (proto.EntityState != BioService.EntityState.Deleted) proto.Photoid = updatedPhoto == null ? 0 : updatedPhoto.Id; BioService.Visitor updatedVisitor = _visitors.UpdateFromProto(proto); if (updatedVisitor == null) return null; updatedVisitor.Photo = updatedPhoto; if (proto.EntityState == BioService.EntityState.Deleted) { IQueryable<Photo> allphotos = _photos.Select().Where(x => x.Id == proto.Photoid); foreach (Photo cp in allphotos) { _photos.Remove(cp); updatedVisitor.Photoid = cp.Id; } } return updatedVisitor; }
private BioService CreateBioService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new BioService(userId); return(service); }
public BioService.VisitorList Select(BioService.CommandVisitors command) { BioService.VisitorList result = new BioService.VisitorList(); DbSet<Visitor> visitors = _visitors.Select(); //DbSet<Photo> photos = _photos.Select(); if (visitors == null) return result; foreach (Visitor visitor in visitors) { BioService.Visitor protoVisitor = _convertor.GetVisitorProto(visitor); if (protoVisitor == null) continue; //long visitorid = visitor.Id; /* Photo visitorPhoto = photos.Where(x => x.Id == visitor.Photo_ID).FirstOrDefault(); BioService.Photo currentPhotoProto = _convertor.GetPhotoProto(visitorPhoto); protoVisitor.Photo = currentPhotoProto; */ result.Visitors.Add(protoVisitor); } return result; }
public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new BioService(userId); var model = service.GetBios(); return(View(model)); }
public BioService.LocationList Update(BioService.LocationList proto) { BioService.LocationList locations = new BioService.LocationList(); foreach (BioService.Location curProto in proto.Locations) { BioService.Location updatedProto = Update(curProto); if (updatedProto != null) locations.Locations.Add(updatedProto); } return locations; }
public BioService.PersonList Update(BioService.PersonList proto) { BioService.PersonList persons = new BioService.PersonList(); foreach (BioService.Person curProto in proto.Persons) { BioService.Person updatedProto = Update(curProto); if (updatedProto != null) persons.Persons.Add(updatedProto); } return persons; }
public BioService.VisitorList Update(BioService.VisitorList proto) { BioService.VisitorList visitors = new BioService.VisitorList(); foreach (BioService.Visitor curProto in proto.Visitors) { BioService.Visitor updatedProto = Update(curProto); if (updatedProto != null) visitors.Visitors.Add(updatedProto); } return visitors; }
public BioService.Location Update( BioService.Location proto ) { BioService.Location updated = _locations.UpdateFromProto(proto); if (updated == null) return null; if (updated.Id == 0) return updated; IQueryable<AccessDevice> accessDevicesToRemove = _accessDevices.Select().Where(x => x.Location_Id == updated.Id); foreach (AccessDevice ac in accessDevicesToRemove) _accessDevices.Remove(ac); IQueryable<CaptureDevice> captureDevicesToRemove = _captureDevices.Select().Where(x => x.Location_Id == updated.Id); foreach (CaptureDevice cp in captureDevicesToRemove) _captureDevices.Remove(cp); long targetID = updated.Id; foreach (BioService.AccessDevice ac in proto.AccessDevices) { if (ac.Locationid != targetID) ac.Locationid = targetID; BioService.AccessDevice updatedADProto = _accessDevices.UpdateFromProto(ac); if (updatedADProto != null) updated.AccessDevices.Add(updatedADProto); } foreach (BioService.CaptureDevice ac in proto.CaptureDevices) { if (ac.Locationid != targetID) ac.Locationid = targetID; BioService.CaptureDevice updatedCDProto = _captureDevices.UpdateFromProto(ac); if (updatedCDProto != null) updated.CaptureDevices.Add(updatedCDProto); } return updated; }
public BioService.LocationList Select( BioService.CommandLocations command) { BioService.LocationList result = new BioService.LocationList(); DbSet<Location> locations = _locations.Select(); DbSet<AccessDevice> accessDevices = _accessDevices.Select(); DbSet<CaptureDevice> captureDevices = _captureDevices.Select(); foreach (Location location in locations) { BioService.Location protoLocation = _convertor.GetLocationProto(location); if (protoLocation == null) continue; long locationid = location.Id; IQueryable<AccessDevice> locationAccessDevices = accessDevices.Where(x => x.Location_Id == locationid); foreach (AccessDevice ac in locationAccessDevices) { BioService.AccessDevice currentAccessDeviceProto = _convertor.GetAccessDeviceProto(ac); if (currentAccessDeviceProto != null) protoLocation.AccessDevices.Add(currentAccessDeviceProto); } IQueryable<CaptureDevice> locationCaptureDevices = captureDevices.Where(x => x.Location_Id == locationid); foreach (CaptureDevice ac in locationCaptureDevices) { BioService.CaptureDevice currentCaptureDeviceProto = _convertor.GetCaptureDeviceProto(ac); if (currentCaptureDeviceProto != null) protoLocation.CaptureDevices.Add(currentCaptureDeviceProto); } result.Locations.Add(protoLocation); } return result; }
public Person GetPersonEntity(BioService.Person proto) { if (proto == null) return null; Person entity = new Person(); entity.Id = proto.Id; entity.First_Name_ = proto.Firstname; entity.Last_Name_ = proto.Lastname; entity.Gender = (byte)proto.Gender; entity.Country = proto.Country; entity.Email = proto.Email; entity.City = proto.City; entity.Comments = proto.Comments; entity.Rights = (byte)proto.Rights; DateTime dateofbirth = new DateTime(proto.Dateofbirth); if (dateofbirth > DateTime.MinValue && dateofbirth < DateTime.MaxValue) entity.Date_Of_Birth = dateofbirth; entity.Thumbnail = proto.Thumbnailid; return entity; }
public BioService.PersonList Select(BioService.CommandPersons command) { BioService.PersonList result = new BioService.PersonList(); DbSet<Person> persons = _persons.Select(); DbSet<Photo> photos = _photos.Select (); DbSet<Card> cards = _cards.Select() ; foreach (Person person in persons) { BioService.Person protoPerson = _convertor.GetPersonProto(person); if (protoPerson == null) continue; long personid = person.Id; //long thumbnailid = 0; //if (person.Thumbnail.HasValue) // thumbnailid = person.Thumbnail.Value; /* Photo thumbnail = photos.Where(x => x.Id == thumbnailid).FirstOrDefault(); if (thumbnail != null) protoPerson.Thumbnail = _convertor.GetPhotoProto(thumbnail); */ /* IQueryable<Photo> personPhotos = photos.Where(x => x.Id != thumbnailid && x.Person_Id == personid); foreach (Photo ph in personPhotos) { BioService.Photo currentPersonProto = _convertor.GetPhotoProto(ph); if (currentPersonProto != null) protoPerson.Photos.Add(currentPersonProto); } */ IQueryable<Card> personCards = cards.Where(x => x.Person_Id == personid); foreach (Card card in personCards) { BioService.Card currentCardProto = _convertor.GetCardProto(card); if (currentCardProto != null) protoPerson.Cards.Add(currentCardProto); } result.Persons.Add(protoPerson); } return result; }
public AccessDevice GetAccessDeviceEntity(BioService.AccessDevice proto) { if (proto == null) return null; AccessDevice entity = new AccessDevice(); entity.Id = proto.Id; entity.PortName = proto.Portname; entity.Location_Type = (byte)proto.Type; entity.Location_Id = proto.Locationid; return entity; }
public Photo GetPhotoEntity(BioService.Photo proto) { if (proto == null) return null; Photo entity = new Photo(); entity.Id = proto.Id; entity.Size_Type = (byte)proto.SizeType; entity.Origin_Type = (byte)proto.OriginType; entity.Image_Pathway = proto.FileLocation; entity.Fir_Pathway = proto.FirLocation; entity.Person_Id = proto.Personid; return entity; }
public Visitor GetVisitorEntity(BioService.Visitor proto) { if (proto == null) return null; Visitor entity = new Visitor(); entity.Id = proto.Id; entity.Location_Id = proto.Locationid; entity.Detection_Time = new DateTime(proto.Time); entity.Card_Number = proto.CardNumber; entity.Photo_ID = proto.Photoid; entity.Person_ID = proto.Personid; entity.Status = (byte)proto.Status; return entity; }
public Location GetLocationEntity(BioService.Location proto) { if (proto == null) return null; Location entity = new Location(); entity.Id = proto.Id; entity.Location_Name = proto.LocationName; entity.Description = proto.Description; return entity; }
public CaptureDevice GetCaptureDeviceEntity(BioService.CaptureDevice proto) { if (proto == null) return null; CaptureDevice entity = new CaptureDevice(); entity.Id = proto.Id; entity.Device_Name = proto.Devicename; entity.Location_Id = proto.Locationid; return entity; }
public BioService.Person Update(BioService.Person proto) { BioService.Person updatedPerson = _persons.UpdateFromProto(proto); if (updatedPerson == null) return null; byte targetPhotoState = (byte)BioService.PhotoOriginType.Loaded; if (proto.EntityState == BioService.EntityState.Deleted) { IQueryable<Photo> allphotos = _photos.Select().Where( x => x.Person_Id == updatedPerson.Id && x.Origin_Type.HasValue && x.Origin_Type.Value == targetPhotoState); foreach (Photo cp in allphotos) _photos.Remove(cp); IQueryable<Card> allcards = _cards.Select().Where(x => x.Person_Id == updatedPerson.Id ); foreach (Card cp in allcards) _cards.Remove(cp); return updatedPerson; } if (proto.Thumbnail != null) { proto.Thumbnail.Personid = updatedPerson.Id; proto.Thumbnail.FileLocation = _utils.GetPersonImagePath(updatedPerson.Id); updatedPerson.Thumbnail = _photos.UpdateFromProto(proto.Thumbnail); if (updatedPerson.Thumbnail != null) { updatedPerson.Thumbnailid = updatedPerson.Thumbnail.Id; updatedPerson.Dbresult = BioService.ResultStatus.Failed; updatedPerson.EntityState = BioService.EntityState.Modified; if ( _persons.UpdateFromProto(updatedPerson) != null ) updatedPerson.Dbresult = BioService.ResultStatus.Success; } } long targetID = updatedPerson.Id; foreach (BioService.Photo ph in proto.Photos) { if (ph.Personid != targetID) ph.Personid = targetID; ph.FileLocation = _utils.GetPersonImagePath(updatedPerson.Id); if (ph.Fir != null && ph.Fir.Length > 0) ph.FirLocation = _utils.GetPersonFirPath(updatedPerson.Id); BioService.Photo updatedPhProto = _photos.UpdateFromProto(ph); if (updatedPhProto != null) updatedPerson.Photos.Add(updatedPhProto); } foreach (BioService.Card card in proto.Cards) { if (card.Personid != targetID) card.Personid = targetID; BioService.Card updatedCardProto = _cards.UpdateFromProto(card); if (updatedCardProto != null) updatedPerson.Cards.Add(updatedCardProto); } return updatedPerson; }
public Card GetCardEntity(BioService.Card proto) { if (proto == null) return null; Card entity = new Card(); entity.Id = proto.Id; entity.Unique_Number = proto.UniqueNumber; entity.Person_Id = proto.Personid; return entity; }