예제 #1
0
 public async Task <JsonResult> GetByCategory(string cat, string api)
 {
     try {
         var data = LocationStorageService.GetByCategory(cat, Guid.Parse(api));
         return(Success(LocationStorageVM.MsToVMs(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
예제 #2
0
 public async Task <JsonResult> GetByID(string id, string api)
 {
     try {
         var data = LocationStorageService.GetByIDAPI(Guid.Parse(id), Guid.Parse(api));
         return(Success(LocationStorageVM.MToVM(data)));
     }catch { return(Failed(MessageUtility.ServerError())); }
 }
예제 #3
0
 public async Task <JsonResult> GetByLocationRadius(string lon, string lat, string cat, string api, string rad)
 {
     try {
         var data = LocationStorageService.GetByCategoryLocationRadius(float.Parse(lon) + float.Parse(rad), float.Parse(lat) + float.Parse(rad), cat, Guid.Parse(api));
         return(Success(LocationStorageVM.MsToVMs(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> LSGetByCategory(string id, string aid)
 {
     try {
         var data = LocationStorageService.GetByLCID(Guid.Parse(id));
         var vms  = LocationStorageService.SetSubDatas(data, Guid.Parse(aid));
         return(Success(vms));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
 public async Task <JsonResult> LSGetByID(string id, string oid, string lcid, string aid)
 {
     try {
         var data = LocationStorageService.GetByIDOID(Guid.Parse(id), Guid.Parse(oid), Guid.Parse(lcid));
         var vm   = LocationStorageService.SetSubData(data, Guid.Parse(aid));
         return(Success(vm));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
 //validate email address if it is allowed to be used
 private static bool InsertNewUserInformation(Guid userID, Guid aid, Guid locCatID)
 {
     try {
         var dtid = Guid.NewGuid();
         DateTimeStorageService.Insert(dtid, userID, aid, DateTime.Now, DateTime.Now, Guid.Parse("a2e2d83d-dd8d-4a66-bacf-94ad90344ca7"));
         LocationStorageService.Insert(Guid.NewGuid(), userID, locCatID, 0, 0, "User Location", dtid, false);
         return(true);
     } catch { return(false); }
 }
 public async Task <JsonResult> LSRemove()
 {
     try {
         var id  = Guid.Parse(Request.Form["id"]);
         var oid = Guid.Parse(Request.Form["oid"]);
         if (LocationStorageService.Remove(id, oid))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtilityService.FailedRemove("Location")));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
 //get branches within the radius of the location of the user
 public static List<StoreBranchVM> GetNearestBranchByLocation(Guid storeID, Guid aid, Guid lcid, float radius, float longi, float lat) {
     var data = GetBySID(storeID);
     var vms = SetSubDatas(data, aid, lcid);
     var nbranch = new List<StoreBranchVM>();
     foreach (var vm in vms) {
         //check branches within range based on location
         if (LocationStorageService.IsWithinRange(vm.Geolocation, radius, longi, lat)) {
             nbranch.Add(vm);
         }
     }
     return nbranch;
 }
예제 #9
0
 public async Task <JsonResult> GetByIDAdmin()
 {
     try
     {
         var ownerID = Request.Form["oid"];
         //category
         var cat  = Request.Form["cat"];
         var data = LocationStorageService.GetByOwnerIDCat(ownerID, cat);
         return(Success(LocationStorageVM.MToVM(data)));
     }
     catch { return(Failed(MessageUtility.ServerError())); }
 }
예제 #10
0
 public async Task <JsonResult> UpdateLocation()
 {
     try {
         var oid       = Request.Form["oid"];
         var api       = Guid.Parse(Request.Form["api"]);
         var longitude = float.Parse(Request.Form["longitude"]);
         var latitude  = float.Parse(Request.Form["latitude"]);
         if (LocationStorageService.UpdateLocation(oid, api, longitude, latitude))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> LSUpdate()
 {
     try {
         var id    = Guid.Parse(Request.Form["id"]);
         var oid   = Guid.Parse(Request.Form["oid"]);
         var longi = float.Parse(Request.Form["longi"]);
         var lat   = float.Parse(Request.Form["lat"]);
         var desc  = Request.Form["desc"];
         if (LocationStorageService.Update(id, oid, longi, lat, desc))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtilityService.FailedUpdate("Location")));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
 public async Task <JsonResult> LSInsert()
 {
     try {
         var id    = Guid.Parse(Request.Form["id"]);
         var oid   = Guid.Parse(Request.Form["oid"]);
         var lcid  = Guid.Parse(Request.Form["lcid"]);
         var longi = float.Parse(Request.Form["longi"]);
         var lat   = float.Parse(Request.Form["lat"]);
         var desc  = Request.Form["desc"];
         var dtid  = Guid.Parse(Request.Form["dtid"]);
         var ia    = Boolean.Parse(Request.Form["ia"]);
         if (LocationStorageService.Insert(id, oid, lcid, longi, lat, desc, dtid, ia))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtilityService.FailedInsert("Location")));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
예제 #13
0
 public async Task <JsonResult> Insert()
 {
     try {
         var id               = Guid.Parse(Request.Form["id"]);
         var ownerID          = Request.Form["oid"];
         var api              = Guid.Parse(Request.Form["api"]);
         var longitude        = float.Parse(Request.Form["longitude"]);
         var latitude         = float.Parse(Request.Form["latitude"]);
         var locationCategory = Request.Form["cat"];
         var desc             = Request.Form["desc"];
         if (LocationStorageService.Insert(id, ownerID, api, longitude, latitude, locationCategory, desc))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch {
         return(Failed(MessageUtility.ServerError()));
     }
 }
 public static StoreBranchVM SetSubData(StoreBranch data, Guid aid, Guid lcid)
 {
     var model = StoreBranchVM.MToVM(data);
     model.Geolocation = LocationStorageVM.MToVM(LocationStorageService.GetByIDOID(data.GeoLocationID, data.ID, lcid));
     return model;
 }