public Dictionary <String, Object> getEvents(Decimal user) { // Return if null values are send if ((user <= 0) || (user <= 0)) { return(null); } // Dictionary to be returned and list of chats Dictionary <String, Object> loginData = new Dictionary <string, object>(); // Create instance for mapped functions to DBprocedures to retrive data WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); // Get all the user Events -> "CE" Calendar Events // This var is of type -> ObjectResult<fun_GetOrRetriveAllCoursesFromUser_Result> var dbEventsLazyObjects = dbEntities.fun_GetOrRetriveUserDocuments((long)user, "CE"); // Now Set them into a list List <fun_GetOrRetriveUserDocuments_Result> dbUserEventsList = dbEventsLazyObjects.ToList(); // Solidify them if (dbUserEventsList.Capacity > 0) { userEvents = (List <EventsSerializable>)ReshapeProperties.solidifyDatabaseObjects(dbUserEventsList); } // Lets wrap all into a dictionary loginData.Add("UserEvents", userEvents);; //String testSerialization = JsonConvert.SerializeObject(loginData); // Lets send it back return(loginData); }
public void edit(T entity, Decimal userId) { if (userId <= 0) { return; } Object modelObject = entity; //test.Equals(WeLearnLib.Model.User if (modelObject is Document) { // Cast it to make sure is a Doc Document d = (Document)modelObject; //Create instance for Entities and pass info to procedure to save on database WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); try { // Update the event dbEntities.fun_UpdateUserEvent(d.docUUID, d.docText, (long)d.docVersion, d.docDate, d.docDesc); } catch (Exception ex) { ex.ToString(); } } else if (modelObject is User) { User u = (User)modelObject; String password = u.password; String lastName = u.lastName; String username = u.username; } }
/// <summary> /// This method will retrive all the people for the chat and will use the same class /// to Make them serializable /// </summary> /// <param name="personId"></param> /// <returns></returns> public Dictionary <String, Object> getAllUsersInChatRoom(Decimal personId) { // Check that null or empty was not sent this far because it should've been handled it before if (personId <= 0) { return(null); } // Dictionary to be returned Dictionary <String, Object> loginData = new Dictionary <string, object>(); // Create instance for mapped functions to DBprocedures to retrive data WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); // the var below is of return type -> ObjectResult<fun_GetAllChatUsers_Result> var dbAllChatUsersLazyObjects = dbEntities.fun_GetAllChatUsers((long)personId); // Transform results in a list type List <fun_GetAllChatUsers_Result> dbAllChatUserList = dbAllChatUsersLazyObjects.ToList(); // If its valid send it over to get it solidified if (dbAllChatUserList.Capacity > 0) { chatUsers = (List <UserSerializable>)ReshapeProperties.solidifyDatabaseObjects(dbAllChatUserList); } else { return(null); } // Lets wrap all into a dictionary loginData.Add("chatUsers", chatUsers); return(loginData); }
public void remove(T entity, Decimal userId) { if (userId <= 0) { return; } Object modelObject = entity; //test.Equals(WeLearnLib.Model.User if (modelObject is Document) { // Cast it to make sure is a Doc Document d = (Document)modelObject; //Create instance for Entities and pass info to procedure to save on database WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); try { //dbEntities.fun_InsertUserEvent(d.docUUID, d.docType, d.docContext, d.docText, (long)d.docVersion, d.docDate, d.docDesc, (long)userId); dbEntities.spDeleteUserEvent(d.docUUID); // GO back to see if we can land on the next line to be exec from the method that called this method, otherwise is going to retun all the way // Without executing anything else //return; // Technically if it goes wrong its going to return failure and its going to send the view that status of the failure this logging the person // out, this is just in the mean time that I make the storce proce return a confirmation of success on the transaction } catch (Exception ex) { ex.ToString(); } } else if (modelObject is User) { User u = (User)modelObject; String password = u.password; String lastName = u.lastName; String username = u.username; } }
public Dictionary <String, Object> getChatConversation(Decimal personLoggedIn, Decimal personChattingWith) { // Return if null values are send if ((personLoggedIn <= 0) || (personChattingWith <= 0)) { return(null); } // Dictionary to be returned and list of chats Dictionary <String, Object> loginData = new Dictionary <string, object>(); chatMessagesList = new List <ChatMessagesSerializable>(); // Create instance for mapped functions to DBprocedures to retrive data WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); // Call Function mapped to Sto Proc type -> ObjectResult<spGetUserChatConversation_Result> var dbAllChatConversation = dbEntities.spGetUserChatConversation((long)personLoggedIn, (long)personChattingWith); // Transform results in a list type List <spGetUserChatConversation_Result> dbChatConversation = dbAllChatConversation.ToList(); // If its valid send it over to get it solidified if (dbChatConversation.Capacity > 0) { foreach (var chatConversation in dbChatConversation) { chatMessagesList.Add(new ChatMessagesSerializable(chatConversation.docText)); } } else { return(null); } // Lets wrap all into a dictionary loginData.Add("chatMessages", chatMessagesList); return(loginData); }
/// <summary> /// This Method will validate against the DB through a store proc to see /// if the user is indeed valid, if so then it will send the object to be /// solidify because by itself it won't be serializable due to its lazy dependencies /// Plus we want to send back only data that is important, not the username and password /// again since it can be hacked. /// Now that I think about it I would have to refactor as I did all in this function /// instead of delegating the work to the Document facade for the events and for the courses /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public Dictionary <String, Object> login(String username, String password) { // Check that null or empty was not sent this far because it should've been handled it before if (username == null || username == "" || username == "undefined" && password == null || password == "" || password == "undefined") { return(null); } // Create instance for mapped functions to DBprocedures to retrive data WeLearnDBmsEntities dbEntities = new WeLearnDBmsEntities(); // Dictionary to be returned Dictionary <String, Object> loginData = new Dictionary <string, object>(); // Obtain results based on whether the person with username and password exists on the system // the var below is of return type -> ObjectResult<fun_IsUserInSystem_Result> var dbUserPropertiesLazyObjects = dbEntities.fun_IsUserInSystem(username, password); // Transform results in a list type -> List<fun_IsUserInSystem_Result> List <fun_IsUserInSystem_Result> dbUserProfileList = dbUserPropertiesLazyObjects.ToList(); // If list is empty then user is not valid since it did not validate againts the DB // If its valid send it over to get it solidified if (dbUserProfileList.Capacity > 0) { user = (UserSerializable)ReshapeProperties.solidifyDatabaseObjects(dbUserProfileList); } else { return(null); } // By now the user is validated and we have the user profile. Now retrive User Raw Courses Data // Return type -> ObjectResult<fun_GetOrRetriveAllCoursesFromUser_Result> var dbUserCoursesLazyObjs = dbEntities.fun_GetOrRetriveAllCoursesFromUser((long)user.getPersonId()); // Make the Complex object into a list List <fun_GetOrRetriveAllCoursesFromUser_Result> dbUserCoursesList = dbUserCoursesLazyObjs.ToList(); // Solidify User Courses if (dbUserCoursesList.Capacity > 0) { userCourses = (List <CoursesSerializable>)ReshapeProperties.solidifyDatabaseObjects(dbUserCoursesList); } // Get all the user Events -> "CE" Calendar Events // This var is of type -> ObjectResult<fun_GetOrRetriveAllCoursesFromUser_Result> var dbEventsLazyObjects = dbEntities.fun_GetOrRetriveUserDocuments((long)user.getPersonId(), "CE"); // Now Set them into a list List <fun_GetOrRetriveUserDocuments_Result> dbUserEventsList = dbEventsLazyObjects.ToList(); // Solidify them if (dbUserEventsList.Capacity > 0) { userEvents = (List <EventsSerializable>)ReshapeProperties.solidifyDatabaseObjects(dbUserEventsList); } // Lets wrap all into a dictionary loginData.Add("UserProfile", user); loginData.Add("UserCouses", userCourses); loginData.Add("UserEvents", userEvents);; //String testSerialization = JsonConvert.SerializeObject(loginData); // Lets send it back return(loginData); }