예제 #1
0
        public static MessageDto AddFloorplanImage(int id, string base64, int pixelsPerFoot)
        {
            using (var uow = new BlueprintUnitOfWork())
            {
                var fp = uow.FloorPlans.Find(id);
                if (fp == null)
                {
                    return new MessageDto("Could not find floorplan");
                }
                if (!string.IsNullOrWhiteSpace(fp.CalibrationImagePath))
                {
                    return new MessageDto("Image already exists. Use PUT verb to update image.");
                }
                string path = fp.SaveImageToDisk(base64);
                string filename = path.Substring(path.LastIndexOf('/'));
                string datagridFile = fp.GetDataGridPath();
                fp.DataGridUrl = string.Format(Defs.DataGridUrl, datagridFile);
                fp.CalibrationImagePath = string.Format(Defs.ImageUrl, filename);
                fp.PixelsPerFoot = pixelsPerFoot;

                // Execute the script for image processing
                string dataGridFilePath = Defs.DataGridDirectory + datagridFile;
                var dto = ExecuteImageProcessorScript(path, fp.Id, pixelsPerFoot, dataGridFilePath);
                if (dto.Result)
                {
                    uow.Save();
                    return dto;
                }
                // If failed delete image
                File.Delete(path);
                return new MessageDto("An error occured while processing the image. The image was not saved.\n" + dto.Message);
            }
        }
 public static NavPoiDto CreateNavPoi(NavPoiRequestDto.NavPoiAdd post)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = post.ToEntity();
         uow.Save();
         return poi.ToDto();
     }
 }
예제 #3
0
 public static PoiDto CreatePoi(PoiRequestDto.PointOfInterestAdd addPoi)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var fp = uow.FloorPlans.Find(addPoi.FloorPlanId);
         var poi = addPoi.ToEntity();
         fp.PointsOfInterest.Add(poi);
         poi.Location.FloorPlan = fp;
         uow.FloorPlanLocations.Add(poi.Location);
         uow.Save();
         return poi.ToDto();
     }
 }
예제 #4
0
 public static MessageDto DeleteBlueprint(int blueprintId, int userId)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var bp = uow.BluePrints.Find(blueprintId);
         if (!IsBluePrintOwner(bp, userId))
         {
             return new MessageDto("Could not find blueprint.");
         }
         uow.BluePrints.Delete(bp);
         uow.Save();
         return new MessageDto(true);
     }
 }
 public static MessageDto DeleteVertPoi(int poiId, int userId, int blueprintId)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var vertpoi = uow.VerticalPois.Find(poiId);
         if (!IsVertPoiOwner(vertpoi, userId, blueprintId))
         {
             return new MessageDto("Could not find point of interest.");
         }
         uow.VerticalPois.Delete(vertpoi);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #6
0
 public static MessageDto DeleteBeacon(int beaconId, int userId, int blueprintId, int floorplanId)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var beacon = uow.Beacons.Where(b => b.Id == beaconId).FirstOrDefault();
         if (!IsBeaconOwner(beacon, userId, blueprintId, floorplanId))
         {
             return new MessageDto("Could not find beacon.");
         }
         uow.Beacons.Delete(beacon);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #7
0
 public static MessageDto DeletePoi(int poiId, int userId, int blueprintId, int floorplanId)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = uow.PointsOfInterest.Find(poiId);
         if (!IsPoiOwner(poi, userId, blueprintId, floorplanId))
         {
             return new MessageDto("Could not find point of interest.");
         }
         uow.PointsOfInterest.Delete(poi);
         uow.Save();
         return new MessageDto(true);
     }
 }
 public static MessageDto AddUpdateNavigationalPoiThumbnail(int id, string base64)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = uow.VerticalPois.Find(id);
         if (poi == null)
         {
             return new MessageDto("Could not find point of interest.");
         }
         poi.ThumbnailPath = poi.SaveThumbnailToDisk(base64);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #9
0
 public static MessageDto AddUpdatePoiThumbnail(int id, string base64)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = uow.PointsOfInterest.Find(id);
         if (poi == null)
         {
             return new MessageDto("Could not find point of interest.");
         }
         var image = Convert.FromBase64String(base64);
         poi.ThumbnailPath = poi.SaveThumbnailToDisk(base64);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #10
0
 public static MessageDto AddUpdateUserFloorPlanImage(int id, string base64, int pixelsPerFoot = Defs.PixelsPerFoot)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var fp = uow.FloorPlans.Find(id);
         if (fp == null)
         {
             return new MessageDto("Could not find floorplan.");
         }
         string path = fp.SaveImageToDisk(base64, true);
         string filename = path.Substring(path.LastIndexOf('/'));
         fp.UserImagePath = string.Format(Defs.ImageUrl, filename);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #11
0
        public static BluePrintDto CreateBluePrint(BluePrintRequestDtos.BluePrintAdd createDto)
        {
            using (var uow = new BlueprintUnitOfWork())
            {
                var user = uow.Users.Find(createDto.UserId);
                if (user == null ||
                    user.BluePrints.FirstOrDefault(b => b.Name == createDto.BluePrintName) != null)
                {
                    return null;
                }
                var bp = createDto.ToEntity();
                user.BluePrints.Add(bp);
                uow.Save();
                return bp.ToDto();

            }
        }
예제 #12
0
        public static BeaconDto AddBeacon(BeaconRequestDtos.BeaconAdd addDto)
        {
            using (var uow = new BlueprintUnitOfWork())
            {
                // Check if the floorplan exists and the beacon has not been added
                var fp = uow.FloorPlans.Where(b => b.Id == addDto.FloorPlanId).FirstOrDefault();
                if (fp == null)
                {
                    return null;
                }

                // Map to Beacon object
                var beacon = addDto.ToEntity();
                fp.Beacons.Add(beacon);
                uow.Save();
                return beacon.ToDto();
            }
        }
예제 #13
0
 public static MessageDto DeleteFloorPlan(int userId, int floorplanId)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var fp = uow.FloorPlans.Find(floorplanId);
         if (!IsFloorplanOwner(fp, userId))
         {
             return new MessageDto("Could not find floorplan.");
         }
         uow.FloorPlans.Delete(fp);
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #14
0
 public static MessageDto UpdateBeacon(int id, string name, string address, bool isNew = false)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var beacon = uow.Beacons.Where(b => b.Id == id).FirstOrDefault();
         if (beacon == null)
         {
             return new MessageDto("Could not find beacon.");
         }
         beacon.Name = name;
         beacon.Address = address;
         beacon.LastModified = DateTime.UtcNow;
         if (isNew)
         {
             beacon.InstallationDate = DateTime.UtcNow;
         }
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #15
0
        public static MessageDto UpdateFloorPlan(int id, int floor, string floorDesc)
        {
            using (var uow = new BlueprintUnitOfWork())
            {
                var fp = uow.FloorPlans.Find(id);

                // Ensure the floorplan exists and the floor the new floorplan represents is not already taken
                if (fp == null)
                {
                    return new MessageDto("Could not find floorplan.");
                }
                if (fp.Blueprint.FloorPlans.FirstOrDefault(f => f.Floor == floor) != null)
                {
                    return new MessageDto(string.Format("A floorplan already exists on floor {0}", floor));
                }
                fp.Floor = floor;
                fp.FloorDesc = floorDesc;
                uow.Save();
                return new MessageDto(true);
            }
        }
예제 #16
0
 public static MessageDto UpdateBeaconLocation(int id, double xPos, double yPos)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var beacon = uow.Beacons.Where(b => b.Id == id).FirstOrDefault();
         if (beacon == null)
         {
             return new MessageDto("Could not find beacon.");
         }
         beacon.Location.XPos = xPos;
         beacon.Location.YPos = yPos;
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #17
0
 public static FloorPlanDto CreateFloorPlan(FloorPlanRequestDto.FloorplanAdd addFp)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         // Ensure blueprint exists and a floorplan does not already exist on the same floor
         var bp = uow.BluePrints.Find(addFp.BluePrintId);
         if (bp == null || bp.FloorPlans.FirstOrDefault(f => f.Floor == addFp.Floor) != null)
         {
             return null;
         }
         var fp = addFp.ToEntity();
         bp.FloorPlans.Add(fp);
         uow.Save();
         return fp.ToDto();
     }
 }
예제 #18
0
 public static MessageDto UpdatePoiLocation(int id, double xPos, double yPos)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = uow.PointsOfInterest.Find(id);
         if (poi == null)
         {
             return new MessageDto("Could not find point of interest.");
         }
         poi.Location.XPos = xPos;
         poi.Location.YPos = yPos;
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #19
0
 public static MessageDto UpdateBluePrint(int id, string name, string country, string state, string city, string region)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var bp = uow.BluePrints.Find(id);
         if (bp == null)
         {
             return new MessageDto("Could not find blueprint.");
         }
         bp.Country = country;
         bp.City = city;
         bp.State = state;
         bp.Region = region;
         bp.Name = name;
         uow.Save();
         return new MessageDto(true);
     }
 }
예제 #20
0
 public static MessageDto UpdatePoi(int id, string name, string description)
 {
     using (var uow = new BlueprintUnitOfWork())
     {
         var poi = uow.PointsOfInterest.Find(id);
         if (poi == null)
         {
             return new MessageDto("Could not find point of interest.");
         }
         poi.Name = name;
         poi.Description = description;
         uow.Save();
         return new MessageDto(true);
     }
 }