Ejemplo n.º 1
0
 public async Task <JsonResult> QQAUpdate()
 {
     try
     {
         var id        = Guid.Parse(Request.Form["id"]);
         var desc      = Request.Form["desc"];
         var isCorrect = Boolean.Parse(Request.Form["ic"]);
         if (QuizQuestionAnswerService.Update(id, desc, isCorrect))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     }
     catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 2
0
 public async Task <JsonResult> QQUpdate()
 {
     try
     {
         var id       = Guid.Parse(Request.Form["id"]);
         var qi       = Guid.Parse(Request.Form["qi"]);
         var question = Request.Form["quest"];
         var point    = int.Parse(Request.Form["point"]);
         if (QuizQuestionService.Update(id, qi, question, point))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     }
     catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 3
0
 public async Task <JsonResult> QQInsert()
 {
     try {
         var id     = Guid.Parse(Request.Form["id"]);
         var quest  = Request.Form["quest"];
         var qi     = Guid.Parse(Request.Form["qi"]);
         var order  = int.Parse(Request.Form["order"]);
         var point  = int.Parse(Request.Form["point"]);
         var status = Guid.Parse(Request.Form["status"]);
         if (QuizQuestionService.Insert(id, quest, qi, order, point, status))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> TAInsert()
 {
     try {
         var id  = Guid.Parse(Request.Form["id"]);
         var oid = Guid.Parse(Request.Form["oid"]);
         var api = Guid.Parse(Request.Form["aid"]);
         var ca  = DateTime.Now;
         var et  = DateTime.Parse(Request.Form["et"]);
         var dt  = DateTime.Parse(Request.Form["dt"]);
         if (TimerAppService.Insert(id, oid, api, ca, et, dt))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 5
0
 public async Task <JsonResult> QUAInsert()
 {
     try {
         var id = Guid.Parse(Request.Form["id"]);
         var questionTakerID = Guid.Parse(Request.Form["qtid"]);
         var questionQuizID  = Guid.Parse(Request.Form["qqid"]);
         var quizAnswerID    = Guid.Parse(Request.Form["qaid"]);
         var otherAnswer     = Request.Form["oa"];
         var points          = int.Parse(Request.Form["point"]);
         if (QuizUserAnswerService.Insert(id, questionTakerID, questionQuizID, quizAnswerID, otherAnswer, points))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> Insert()
 {
     try {
         var id      = Guid.NewGuid();
         var lsID    = Guid.Parse(Request.Form["lsID"]);
         var uid     = Guid.Parse(Request.Form["userID"]);
         var isAdmin = Boolean.Parse(Request.Form["isAdmin"]);
         if (LocationSessionParticipantService.Insert(id, uid, lsID, isAdmin))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch {
         return(Failed(MessageUtility.ServerError()));
     }
 }
Ejemplo n.º 7
0
 public async Task <JsonResult> InsertReceipent()
 {
     try {
         var id        = Guid.NewGuid();
         var notifInfo = Guid.Parse(Request.Form["nid"]);
         var rid       = Request.Form["rid"];
         var api       = Guid.Parse(Request.Form["api"]);
         if (NotificationService.InsertNR(id, notifInfo, rid, api))
         {
             var data = NotificationService.GetByID_N(notifInfo, api);
             NotificationManagerHub.SendNotification(id.ToString(), api.ToString(), rid, data.Title, data.Message);
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> Insert()
 {
     try {
         var id       = Guid.NewGuid();
         var comment  = Request.Form["comment"];
         var uid      = Guid.Parse(Request.Form["uid"]);
         var senderID = Guid.Parse(Request.Form["sid"]);
         var api      = Guid.Parse(Request.Form["api"]);
         var stars    = int.Parse(Request.Form["stars"]);
         if (UsersReviewService.Insert(id, comment, uid, senderID, api, DateTime.Now, stars))
         {
             return(Success(id.ToString()));
         }
         return(Success(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 9
0
 public async Task <JsonResult> Insert()
 {
     try
     {
         var id     = Guid.Parse(Request.Form["id"]);
         var api    = Guid.Parse(Request.Form["api"]);
         var oid    = Guid.Parse(Request.Form["oid"]);
         var source = Request.Form["source"];
         if (ImageLinkStorageService.Insert(id, api, oid, source))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     }
     catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 10
0
 public async Task <JsonResult> QIInsert()
 {
     try {
         var id       = Guid.NewGuid();
         var name     = Request.Form["name"];
         var oid      = Guid.Parse(Request.Form["oid"]);
         var appID    = Guid.Parse(Request.Form["aid"]);
         var quizCode = Request.Form["qc"];
         var status   = Guid.Parse(Request.Form["status"]);
         var htl      = Boolean.Parse(Request.Form["htl"]);
         if (QuizInfoService.Insert(id, name, oid, appID, quizCode, status, Guid.Parse("7b3f5e5b-744a-4471-8392-5aa525627547"), htl))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 11
0
 public async Task <JsonResult> Update()
 {
     try {
         var id          = Guid.Parse(Request.Form["id"]);
         var title       = Request.Form["title"];
         var description = Request.Form["description"];
         var price       = float.Parse(Request.Form["price"]);
         var catID       = Guid.Parse(Request.Form["catID"]);
         var archive     = Boolean.Parse(Request.Form["archive"]);
         var postType    = int.Parse(Request.Form["ptype"]);
         if (ItemService.Update(id, title, description, catID, archive, price, postType))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> Insert()
 {
     try {
         var id     = Guid.NewGuid();
         var uid    = Request.Form["uid"];
         var roomID = Guid.Parse(Request.Form["rid"]);
         var api    = Guid.Parse(Request.Form["api"]);
         if (MessagingRoomParticipantService.Insert(id, uid, roomID, api))
         {
             return(Success(id.ToString()));
         }
         else
         {
             return(Failed(MessageUtility.ServerError()));
         }
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> CalculateUserReviews(string id, string api)
 {
     try {
         var data    = UsersReviewService.GetByUserID(Guid.Parse(id), Guid.Parse(api));
         var average = 0;
         if (data.Count > 0)
         {
             int totalStars = 0;
             foreach (var model in data)
             {
                 totalStars += model.Stars;
             }
             average = totalStars / data.Count;
         }
         return(Success("" + average));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> TLInsert()
 {
     try {
         var id   = Guid.Parse(Request.Form["id"]);
         var oid  = Guid.Parse(Request.Form["oid"]);
         var taid = Guid.Parse(Request.Form["taid"]);
         var api  = Guid.Parse(Request.Form["api"]);
         var ca   = DateTime.Now;
         var ts   = DateTime.Parse(Request.Form["ts"]);
         var te   = DateTime.Parse(Request.Form["te"]);
         if (TimerLeftService.Insert(id, oid, taid, api, ca, ts, te))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> Insert()
 {
     try {
         var id           = Guid.NewGuid();
         var title        = Request.Form["title"];
         var description  = Request.Form["description"];
         var api          = Guid.Parse(Request.Form["api"]);
         var itemCategory = Guid.Parse(Request.Form["ic"]);
         var isCount      = Boolean.Parse(Request.Form["isCount"]);
         var storeAPI     = Guid.Parse(Request.Form["spi"]);
         if (IS_ItemService.Insert(id, title, description, api, itemCategory, isCount, 0, storeAPI))
         {
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 16
0
        public async Task <JsonResult> LeaveConnection()
        {
            try {
                var mid = Request.Form["MID"];
                var uid = Request.Form["UID"];
                var cid = Request.Form["CID"];

                var conn = ConnectionServices.GetByID(cid);
                ConnectionMemberService.UpdateMemberStatus(mid, true);
                //if there no active users in this connection then remove this data from the database
                if (conn.Members.Where(x => x.isArchived == false).Count() <= 0)
                {
                    //remove data from database
                    ConnectionMemberService.RemoveMembersByConnectionID(cid);
                    ConnectionServices.RemoveConnection(cid);
                }
                return(Json(new { success = true }));
            } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
        }
Ejemplo n.º 17
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()));
     }
 }
Ejemplo n.º 18
0
        public async Task <JsonResult> UploadBase64()
        {
            try {
                var company = Request.Form["company"];
                var source  = Request.Form["image"];
                var fname   = Guid.NewGuid().ToString();
                //if (!Directory.Exists(Path.Combine(Server.MapPath("~/UPLOADS/" + company))))
                //{
                //    Directory.CreateDirectory(Path.Combine(Server.MapPath("~/UPLOADS/" + company)));
                //}
                var path = Path.Combine(Server.MapPath("~/UPLOADS/" + company), fname.ToString() + ".png");
                //var path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/UPLOADS/" + company),fname.ToString() + ".png");

                var byteData = Convert.FromBase64String(source);
                System.IO.File.WriteAllBytes(path, byteData);
                //UploadUtility.UriToServer(source, path);
                return(Success("/UPLOADS/" + company + "/" + fname.ToString() + ".png"));
            } catch { return(Failed(MessageUtility.ServerError())); }
        }
Ejemplo n.º 19
0
 public async Task <JsonResult> Insert(AddOnViewModel vm)
 {
     try {
         if (APISecurity.IsAllowAPIAccessByKey(roleName, "Admin"))
         {
             vm.ID      = Guid.NewGuid().ToString();
             vm.Company = new CompanyViewModel()
             {
                 ID = CurrentUser.CompanyID
             };
             var model = AddOnUtility.VMToM(vm);
             _addOnService.Insert(model);
             return(Json(new { success = true }));
         }
         else
         {
             return(Json(new { success = false, message = MessageUtility.NoAccessPriviledges() }));
         }
     } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
 }
Ejemplo n.º 20
0
 public async Task <JsonResult> Insert()
 {
     try {
         var id          = Guid.NewGuid();
         var title       = Request.Form["title"];
         var description = Request.Form["description"];
         var price       = float.Parse(Request.Form["price"]);
         var ownerID     = Guid.Parse(Request.Form["ownerID"]);
         var categoryID  = Guid.Parse(Request.Form["catID"]);
         var longitude   = float.Parse(Request.Form["longitude"]);
         var latitude    = float.Parse(Request.Form["latitude"]);
         var api         = Guid.Parse(Request.Form["API"]);
         var postType    = int.Parse(Request.Form["ptype"]);
         if (ItemService.Insert(id, title, description, price, ownerID, categoryID, longitude, latitude, false, api, DateTime.Now, DateTime.Now, postType))
         {
             return(Json(new { success = true, data = id }));
         }
         return(Json(new { success = false, message = MessageUtility.ServerError() }));
     } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
 }
Ejemplo n.º 21
0
 public async Task <JsonResult> Insert()
 {
     try {
         var id    = Guid.NewGuid();
         var apiID = Guid.Parse(Request.Form["api"]);
         //companyID
         var cid     = Guid.Parse(Request.Form["cid"]);
         var title   = Request.Form["title"];
         var message = Request.Form["message"];
         //insert Notification
         if (NotificationService.Insert(id, message, apiID, title))
         {
             return(Success(id.ToString()));
         }
         else
         {
             return(Failed(MessageUtility.APIKeyError()));
         }
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 22
0
 public async Task <JsonResult> NotificationReceived()
 {
     try {
         var id   = Guid.Parse(Request.Form["id"]);
         var api  = Guid.Parse(Request.Form["api"]);
         var data = NotificationService.GetByID_NR(id, api);
         if (NotificationService.Remove_NR(id, api))
         {
             //check if notification still have notification receipent else
             //delete from database
             var list = NotificationService.GetByNotificationID_NR(data.ID);
             if (list.Count <= 0)
             {
                 NotificationService.Remove_N(data.NotificationInfo, api);
             }
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 23
0
 public async Task <JsonResult> CheckOwnerNotification()
 {
     try {
         var api = Guid.Parse(Request.Form["api"]);
         var cid = Guid.Parse(Request.Form["cid"]);
         var uid = Request.Form["uid"];
         //check user receipent
         var receipents = NotificationService.GetByUIDAPI_NR(uid, api);
         if (receipents.Count > 0)
         {
             foreach (var r in receipents)
             {
                 var data = NotificationService.GetByID_N(r.NotificationInfo, r.API);
                 //receipent Notification ID so it can be removed
                 NotificationManagerHub.SendNotification(r.ID.ToString(), data.apiKey.ToString(), r.ReceiverID, data.Title, data.Message);
             }
         }
         return(Success(""));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
Ejemplo n.º 24
0
 public async Task <JsonResult> Insert()
 {
     try {
         var id       = Guid.NewGuid();
         var api      = Guid.Parse(Request.Form["api"]);
         var compID   = Guid.Parse(Request.Form["cid"]);
         var roomName = Request.Form["name"];
         //first check if api is valid
         var access = CompanyAPIKeyService.GetByAPIKeyCompID(api, compID);
         if (access != null)
         {
             //if api is valid insert room
             if (CloudMessagingRoomService.Insert(id, roomName, api, false))
             {
                 //returns the id of the room
                 return(Json(new { success = true, data = id }));
             }
             return(Json(new { success = false, message = MessageUtility.DidNotFollowStandardUsingAPI() }));
         }
         return(Json(new { success = false, message = MessageUtility.APIKeyError() }));
     } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
 }
Ejemplo n.º 25
0
        public async Task <JsonResult> Image()
        {
            try {
                var company  = Request.Form["path"];
                var fileName = "file0";
                foreach (string file in Request.Files)
                {
                    var fileContent = Request.Files[file];
                    if (fileContent != null && fileContent.ContentLength > 0)
                    {
                        //before uploading image make sure it does not exist in path
                        // get a stream
                        var stream = fileContent.InputStream;
                        // and optionally write the file to disk
                        var path  = Path.Combine(Server.MapPath("~/UPLOADS/" + company), fileName + ".png");
                        var index = 0;
                        while (true)
                        {
                            if (!UploadUtility.IsExist(path))
                            {
                                break;
                            }
                            else
                            {
                                index++;
                                fileName = "file" + index;
                                path     = Path.Combine(Server.MapPath("~/UPLOADS/" + company), fileName + ".png");
                            }
                        }

                        using (var fileStream = System.IO.File.Create(path))
                        {
                            stream.CopyTo(fileStream);
                        }
                    }
                }
                return(Json(new { success = true, data = "UPLOADS/" + company + "/" + fileName + ".png" }));
            } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
        }
Ejemplo n.º 26
0
 public async Task <JsonResult> GetConnectionMemberUpdatedLocation(string connection)
 {
     try {
         ConnectionViewModel param = json_serializer.Deserialize <ConnectionViewModel>(connection);
         var connectionData        = ConnectionServices.GetByID(param.ID);
         var temp = new ConnectionViewModel()
         {
             ID        = param.ID,
             GroupName = param.GroupName
         };
         foreach (var member in connectionData.Members)
         {
             if (member.isArchived == false)
             {
                 var vm = new UserInformationViewModel()
                 {
                     User = member.UserID.ToString(),
                 };
                 temp.PushMembers(member, vm);
             }
         }
         return(Json(new { success = true, data = temp }, JsonRequestBehavior.AllowGet));
     } catch { return(Json(new { success = false, message = MessageUtility.ServerError() }, JsonRequestBehavior.AllowGet)); }
 }
        public async Task <JsonResult> AcceptRequest()
        {
            try {
                var rid = Request.Form["RID"];
                //connID
                var cid = Request.Form["CID"];
                //recquestTo UID
                var rtID = Request.Form["RTID"];
                //checks if it is already existing
                var data = ConnectionServices.GetByUIDConnectionID(rtID, cid);
                if (data == null)
                {
                    //create if not existing yet
                    var id = Guid.NewGuid();
                    ConnectionMemberService.InsertMember(id, Guid.Parse(rtID), cid, DateTime.Now, false, false);
                    RequestService.UpdateStatus(true, rid);
                    //signalR notify accepted request is a standalone now if you want to invoke it please  access it via api
                    return(Json(new { success = true }));
                }
                else if (data.isArchived)
                {
                    //if data already exist then unarchive it
                    ConnectionMemberService.UpdateMemberStatus(data.ID.ToString(), false);
                    RequestService.UpdateStatus(true, rid);
                    //signalR notify accepted request is a standalone now if you want to invoke it please  access it via api
                    return(Json(new { success = true }));
                }
                else if (!data.isArchived)
                {
                    RequestService.UpdateStatus(true, rid);
                    return(Json(new { success = false, message = MessageUtility.AlreadyMember() }));
                }

                return(Json(new { success = false, message = MessageUtility.ServerError() }));
            } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
        }
Ejemplo n.º 28
0
 private JsonResult Failed(string message)
 {
     return(Json(new { success = false, message = MessageUtility.ServerError() }, JsonRequestBehavior.AllowGet));
 }
 public async Task <JsonResult> GenerateUID()
 {
     try{
         return(Success(Guid.NewGuid().ToString()));
     }catch { return(Failed(MessageUtility.ServerError())); }
 }