public void AddToBooking_NegativeTestCases_UserStatusInvalid() { Book toBeBooked = new Book(); toBeBooked.RenterId = 2; toBeBooked.RoomId = 3; Book booked = new Book(); booked.BookId = 1; booked.RenterId = 2; booked.RoomId = 3; BookingReceived bookingReceived = new BookingReceived(); bookingReceived.RenterId = 2; bookingReceived.RoomId = 3; Acknowledgement <Book> bookAcknowledgement = new Acknowledgement <Book>(); bookAcknowledgement.code = 0; bookAcknowledgement.Set = null; bookAcknowledgement.Message = "failed to book"; //Assign var _mockBusinessMethod = new Mock <BookingManager>(); // var Wish_List = RemoveFromWishList_Mock_Negative(); _mockBusinessMethod.Setup(p => p.AddToBooking(toBeBooked)).Throws(new UserStatusInvalid()); BookingController _bookingController = new BookingController(_mockBusinessMethod.Object); //Act var _returnedBooking = _bookingController.AddToBooking(bookingReceived); var _returnedBookingAck = _returnedBooking as OkObjectResult; var _originalReturnedBookingAck = bookAcknowledgement; //Assert Assert.IsNotNull(_returnedBookingAck); Assert.ReferenceEquals(_returnedBookingAck.Value, _originalReturnedBookingAck); }
public async void Run_NewTransactionDisplayTest() { ShowTestOnTerminal("NewTransactionDisplay"); TransactionDisplayRequest request = new TransactionDisplayRequest { Test = true, TerminalName = IntegrationTestConfiguration.Instance.Settings.DefaultTerminalName, Transaction = new TransactionDisplayTransaction { Subtotal = "35.00", Tax = "5.00", Total = "70.00", Items = new List <TransactionDisplayItem> { new TransactionDisplayItem { Description = "Leki Trekking Poles", Price = "35.00", Quantity = 2, Extended = "70.00", Discounts = new List <TransactionDisplayDiscount> { new TransactionDisplayDiscount { Description = "memberDiscount", Amount = "10.00", } }, } }, }, }; output.WriteLine("Request: {0}", request); Acknowledgement response = await blockchyp.NewTransactionDisplayAsync(request); output.WriteLine("Response: {0}", response); Assert.True(response.Success, "response.Success"); }
public IActionResult ForgetPassword(string email, string password) { Acknowledgement <User> payload = new Acknowledgement <User>(); try { //ForgetPasswordType forgetPasswordType = new ForgetPasswordType(); if (email.Equals(null)) { //return BadRequest(password); throw new Exception("Email should not be empty"); } if (password.Equals(null)) { //return BadRequest(password); throw new Exception("Password should not be empty"); } payload.Message = usermanager.ForgetPasswordManager(email, password); payload.code = 1; payload.Set = null; if (payload.Message == "Email does not exist") { //return BadRequest(email); throw new Exception("Email does not exist"); } if (payload.Message.Equals("Invalid Email")) { throw new Exception("Invalid Email"); } if (payload.Message.Equals("Invalid Password")) { throw new Exception("Invalid Password"); } } catch (Exception ex) { payload.code = 2; payload.Set = null; payload.Message = ex.Message; } return(Ok(payload)); }
public void GetUserdata_NegativeTestCases_TestResults() { //Assign var userId = 1; var _returnAckType = new Acknowledgement <UserUpdateHelp> { code = 3, Set = null, Message = "Something went wrong. Please try again later" }; var _mockUserMethod = new Mock <UserManager>(); _mockUserMethod.Setup(p => p.GetUser(userId)).Throws <System.Exception>(); UserController _userController = new UserController(_mockUserMethod.Object); //Act var _actualReturnType = _userController.GetUserdata(userId) as OkObjectResult; //Assert Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void EmailPassword_NegativeUserTestCases_Exception_TestResults() { //Assign string email = "*****@*****.**"; var _mockUserMethod = new Mock <UserManager>(); var _returnAckType = new Acknowledgement <UserPutHelp> { code = 2, Set = null, Message = "System Object Reference missing" }; _mockUserMethod.Setup(p => p.EmailPasswordManager(email)).Throws <System.Exception>(); UserController _userController = new UserController(_mockUserMethod.Object); //Act var _actualReturnType = _userController.EmailPassword(email) as OkObjectResult; //Assert Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void GetCities_Negative_CitiesReturned() { //Arrange. var _mockDataService = new Mock <SearchCityTypeService>(); _mockDataService.Setup(p => p.GetCities()).Returns(new List <string>()); var _bookingManager = new BookingManager(_mockDataService.Object); var _responseExpected = new Acknowledgement <string> { code = 0, Set = new List <string>(), Message = "No Cities", }; //Act var responseReturned = _bookingManager.GetCities(); //Assert Assert.ReferenceEquals(responseReturned, _responseExpected); }
public void PostUser_PositiveTestCases_TestResults() { //Assign var _mockBusinessMethod = new Mock <UserManager>(); var user_List = GetUsers_Mock_Positive(); var _returnAckType = new Acknowledgement <User> { code = 1, Set = null, Message = "successfully registered" }; _mockBusinessMethod.Setup(p => p.PostUser(user_List)).Returns(_returnAckType); UserController _userController = new UserController(_mockBusinessMethod.Object); //Act var _actualReturnType = _userController.PostUser(user_List) as OkObjectResult; Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void DeleteRoom_Positive() { int RoomId = 10; var MockRoomBusiness = new Mock <RoomManager>(); var returnAckType = new Acknowledgement <Room> { code = 1, Set = null, Message = "Successfully deleted", }; //Act MockRoomBusiness.Setup(p => p.deleteRoomService(RoomId)).Returns(returnAckType); RoomsController roomsController = new RoomsController(MockRoomBusiness.Object); var actualReturnType = roomsController.DeletePropertListing(RoomId) as OkObjectResult; Assert.ReferenceEquals(returnAckType, actualReturnType.Value); }
private Acknowledgement <WishListDuplicate> AddingToWishList_Mock_Positive() { var wishListDuplicate = new WishListDuplicate() { WishListId = 4, RoomId = 4, RenterId = 2 }; List <WishListDuplicate> wishList = new List <WishListDuplicate>(); wishList.Add(wishListDuplicate); var wishList_Ack = new Acknowledgement <WishListDuplicate> { code = 1, Set = wishList, Message = "Success" }; return(wishList_Ack); }
public void PostUser_Negative_AlreadyExists() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "This account already exists." }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
// public IActionResult PostWishList(WishList wishListReceived) public IActionResult PostWishList(WishListToReceive wishListReceived) { //BookingManager bookingManager = new BookingManager(); WishList wishListToBeAdded = new WishList(); wishListToBeAdded.RenterId = wishListReceived.RenterId; wishListToBeAdded.RoomId = wishListReceived.RoomId; Acknowledgement <WishListDuplicate> returnData = new Acknowledgement <WishListDuplicate>(); //to avoid nulls that r present due to foreign key in model class "wishlist" we are using generic for duplicate wishlist. if (!ModelState.IsValid) { returnData = search.WhenErrorOccurs("", type: "modelState"); //this will call a method in bookingManager return(Ok(returnData)); } try { returnData = search.AddingToWishList(wishListToBeAdded); } catch (AlreadyThereInWishList alreadyThere) { returnData = search.WhenErrorOccurs(alreadyThere.Message, type: "post"); //this will call a overloaded method in bookingManager return(Ok(returnData)); } catch (SqlException) { returnData = search.WhenErrorOccurs("", type: "post"); //this will call a overloaded method in bookingManager return(Ok(returnData)); } catch (Exception) { returnData = search.WhenErrorOccurs("", type: "post"); return(Ok(returnData)); } return(Ok(returnData)); }
public virtual Acknowledgement <Room> DisplayWishList(int renterIdReceived) { List <Room> DisplayWishListRooms = new List <Room>(); Acknowledgement <Room> returnData; string message; List <int> renterIdsPresent; bool isRenterPresent = false; try { DisplayWishListRooms = bookingService.DisplayWishList(renterIdReceived); if (DisplayWishListRooms.Count == 0) { renterIdsPresent = bookingService.RenterIdList(); foreach (int i in renterIdsPresent) { if (i == renterIdReceived) { isRenterPresent = true; } } if (isRenterPresent == false) { returnData = new Acknowledgement <Room>(0, DisplayWishListRooms, "Sorry, No renter present with that Id"); return(returnData); } message = "Your wishlist is empty"; } else { message = "Successfully retrieved wishlist"; } returnData = new Acknowledgement <Room>(1, DisplayWishListRooms, message); } catch (Exception ex) { throw ex; } return(returnData); }
private Acknowledgement <UserModified> PutPartner_Mock_Negative_Invalid_UserStatus() { Acknowledgement <UserModified> aknowledgement = new Acknowledgement <UserModified>(); List <UserModified> partnerList = new List <UserModified>(); UserModified PartnerData = new UserModified() { UserId = 1, UserName = "******", UserEmail = "*****@*****.**", UserPhoneNumber = "9823625674", UserAddress = "Nagpur", UserType = "Partner", UserStatus = "sts" }; partnerList.Add(PartnerData); aknowledgement.code = 2; aknowledgement.Set = partnerList; aknowledgement.Message = "UserType is invalid"; return(aknowledgement); }
private Acknowledgement <UserModified> PutPartner_Mock_NegativeTestMismatchedId(UserModified user, int partnerId) { Acknowledgement <UserModified> aknowledgement = new Acknowledgement <UserModified>(); if (user.UserId != partnerId) { aknowledgement.code = 2; aknowledgement.Set = null; aknowledgement.Message = "PartnerId and UserId does not match"; return(aknowledgement); } else { List <UserModified> partnerList = new List <UserModified>(); partnerList.Add(user); aknowledgement.code = 0; aknowledgement.Set = partnerList; aknowledgement.Message = "Success"; return(aknowledgement); } }
public void GetLocation_Positive_CitiesReturnerd() { var _mockDataService = new Mock <BookingService>(); _mockDataService.Setup(p => p.geoLocations(4)).Returns(GetLocationList(4)); var _bookingManager = new BookingManager(_mockDataService.Object); var _responseExpected = new Acknowledgement <GeoLocation> { code = 0, Set = GetLocationList(4), Message = "Location of room on google map" }; //Act var responseReturned = _bookingManager.GetLocation(4); //Assert Assert.ReferenceEquals(responseReturned, _responseExpected); }
public virtual Acknowledgement <WishListDuplicate> DeleteFromWishList(WishListDuplicate wishListDuplicateReceived) { Acknowledgement <WishListDuplicate> returnData; List <WishListDuplicate> wishListDuplicateRooms = new List <WishListDuplicate>(); try { // wishListDuplicateRooms = bookingService.RemoveFromWishList(wishListDuplicateReceived); wishListDuplicateRooms = bookingService.RemoveFromWishList(wishListDuplicateReceived); returnData = new Acknowledgement <WishListDuplicate>(1, wishListDuplicateRooms, "Removed from wishlist"); } catch (NotThereInWishList notThere) { throw notThere; } catch (Exception ex) { throw ex; } return(returnData); }
private Acknowledgement WriteCommand(Command cmd) { _commandID++; Acknowledgement ack = new Acknowledgement(cmd, _commandID); byte[] wbuffer = _protocol.GetWriteBytes(ack); try { _port.Write(wbuffer, 0, wbuffer.Length); Console.Write("Writing: "); Protocol.PrintArray(wbuffer); } catch (IOException) { Console.WriteLine("While writing an IOException occured"); StopConnection(); return(null); } return(ack); }
public virtual Acknowledgement <Image> AddImage(List <byte[]> convertedBytes) { Acknowledgement <Image> ImageAknowledgement = new Acknowledgement <Image>(); try { FindMyRoomDb roomDb = new FindMyRoomDb(); var query = roomDb.FMRRooms.LastOrDefault(); roomImageId = query.RoomId; roomService.UploadImages(convertedBytes, roomImageId); ImageAknowledgement.code = 1; ImageAknowledgement.Set = null; ImageAknowledgement.Message = "Images are Uploaded"; return(ImageAknowledgement); } catch (Exception ex) { throw ex; } }
public void EmailPassword_NegativeUserTestCases_InvalidInput_TestResults() { //Assign string email = "test.gmail.com"; string _message = "Invalid Input"; var _mockUserMethod = new Mock <UserManager>(); var _returnAckType = new Acknowledgement <UserPutHelp> { code = 2, Set = null, Message = _message }; _mockUserMethod.Setup(p => p.EmailPasswordManager(email)).Returns(_message); UserController _userController = new UserController(_mockUserMethod.Object); //Act var _actualReturnType = _userController.EmailPassword(email) as OkObjectResult; //Assert Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void PostRoomsBusiness_Positive() { var MockRoomService = new Mock <RoomService>(); HelperAddRoom room = new HelperAddRoom { PartnerId = 12, Address = "abcdefghijkl", Area = "abdjkieijr", city = "Bangalore", Description = "tough night", Furniture = "yes", NumberOfRooms = 5, Pincode = 123456, RoomCost = 5000, Latitude = "500", RoomType = "flat", Longitude = "600", }; var retAck = new Acknowledgement <Room> { code = 1, Set = null, Message = "Successfully Added" }; int roomId = 10; MockRoomService.Setup(p => p.AddRoom(room)).Returns(roomId); RoomManager roomManager = new RoomManager(MockRoomService.Object); try { var actualReturnType = roomManager.AddingRoom(room); Assert.IsTrue(false); } // var actualRetunType = roomManager.PostRooms(room_List) as OkObjectResult; catch { Assert.IsTrue(true); } }
public void GetUsers_Positive_UserReturned() { //Arrange var _mockDataService = new Mock <UserService>(); var users = new User() { UserAddress = "Hyderabad", UserEmail = "*****@*****.**", UserPassword = "******", UserName = "******", UserPhoneNumber = "9898989898", UserStatus = "valid", UserType = "Admin" }; List <User> list = new List <User>(); list.Add(users); _mockDataService.Setup(p => p.GetDetails()).Returns(list); var _userManager = new UserManager(_mockDataService.Object); var _responseExpected = new Acknowledgement <User> { code = 1, Set = list, Message = "Success" }; var validateuser = new AuthenticateAdmin() { UserEmail = "*****@*****.**", UserPassword = "******", }; //Act var responseReturned = _userManager.Validate(validateuser.UserEmail, validateuser.UserPassword); //Assert Assert.ReferenceEquals(responseReturned, _responseExpected); }
public void ForgetPassword_NegativeUserTestCases_InvalidPassword_TestResults() { //Assign var email = "*****@*****.**"; var password = "******"; var _mockUserMethod = new Mock <UserManager>(); var _message = "Invalid Password"; var _returnAckType = new Acknowledgement <UserPutHelp> { code = 2, Set = null, Message = _message }; _mockUserMethod.Setup(p => p.ForgetPasswordManager(email, password)).Returns(_message); UserController _userController = new UserController(_mockUserMethod.Object); //Act var _actualReturnType = _userController.ForgetPassword(email, password) as OkObjectResult; //Assert Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void EmailPassword_PositiveUserTestCases_TestResults() { //Assign var email = "*****@*****.**"; var _mockUserMethod = new Mock <UserManager>(); var _message = "Mail sent successfully"; var _returnAckType = new Acknowledgement <UserPutHelp> { code = 1, Set = null, Message = _message }; _mockUserMethod.Setup(p => p.EmailPasswordManager(email)).Returns(_message); UserController _userController = new UserController(_mockUserMethod.Object); //Act var _actualReturnType = _userController.EmailPassword(email) as OkObjectResult; //Assert Assert.ReferenceEquals(_returnAckType, _actualReturnType.Value); }
public void PostUser_Negative_UsersPhoneNo() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.MobileNumber = "1234567890"; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "mobile number is invalid it should start with 9/8/7/6 and of length 10." }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Positive_Testresults() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.Email = "*****@*****.**"; var _returnAskType = new Acknowledgement <User> { code = 0, Set = null, Message = "Successfully Registered." }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Negative_UserName() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.UserName = "******"; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "Username is invalid it should consists only characters." }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Negative_Address() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.Address = " "; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "Address field should not be empty" }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Negative_UsersType() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.Type = "admin"; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "user type should be either partner or renter" }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Negative_UsersPassword() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.Password = "******"; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "password is invalid, It should consists atleast one Uppercase,special character and number of length more than 7" }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
public void PostUser_Negative_UsersEmail() { var _mockBussinessMethod = new Mock <UserManager>(); var _usermanager = new UserManager(); HelperAddUser user = GetUsers_Mock_Negative(); user.Email = "shravani@er"; var _returnAskType = new Acknowledgement <User> { code = 2, Set = null, Message = "email is invalid" }; _mockBussinessMethod.Setup(p => p.PostUser(user)).Returns(_returnAskType); //Act var _actualReturnType = _usermanager.PostUser(user) as Acknowledgement <User>; //Assert Assert.ReferenceEquals(_returnAskType, _actualReturnType); }
protected bool Equals(Acknowledgement other) { return string.Equals(CorrelationId, other.CorrelationId); }
public void ProcessRequest(HttpContext context) { // context.Response.ContentType = "text/plain"; // context.Response.CacheControl = "no-cache"; // context.Response.AddHeader("Pragma", "no-cache"); // //context.Response.AddHeader("Pragma", "no-store"); // //context.Response.AddHeader("cache-control", "no-cache"); //context.Response.Cache.SetCacheability(HttpCacheability.NoCache); // context.Response.Cache.SetNoServerCaching(); if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()])) return; SiteEnums.QueryStringNames ptyc = (SiteEnums.QueryStringNames)Enum.Parse(typeof(SiteEnums.QueryStringNames), context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]); // Dictionary<string, Subgurim.Chat.Usuario> usrrs = null; StringBuilder sb = null; MembershipUser mu = null; switch (ptyc) { case SiteEnums.QueryStringNames.status_update: #region status_update string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()]; if (string.IsNullOrEmpty(key)) { key = context.Request.QueryString[SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()]; } int statusUpdateID = Convert.ToInt32(key); StatusUpdate statup = null; if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()])) { mu = Membership.GetUser(); Acknowledgement ack = new Acknowledgement(); ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]); ack.StatusUpdateID = statusUpdateID; statup = new StatusUpdate(statusUpdateID); if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); StatusUpdateNotification sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { // sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.A); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.A); } else if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.B.ToString())) { //sun.GetStatusUpdateNotificationForUserStatus(Convert.ToInt32(mu.ProviderUserKey), statusUpdateID, SiteEnums.ResponseType.B); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.B); } if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun.UserAccountID = statup.UserAccountID; SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.Create(); } else { sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID); } context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}"); } else { // reverse ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statup.StatusAcknowledgements) + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()])) { mu = Membership.GetUser(); StatusCommentAcknowledgement ack = new StatusCommentAcknowledgement(); ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); ack.AcknowledgementType = Convert.ToChar(context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]); ack.StatusCommentID = statusUpdateID; // this is really the commentID (or should be) StatusComment statcomup = new StatusComment(statusUpdateID); statup = new StatusUpdate(statcomup.StatusUpdateID); if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); StatusUpdateNotification sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.A); } else { sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, SiteEnums.ResponseType.B); } if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID) { sun.UserAccountID = statcomup.UserAccountID; SiteEnums.ResponseType rspType = SiteEnums.ResponseType.U; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } if (sun.StatusUpdateNotificationID == 0) { sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Create(); } else { sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, rspType, sun.StatusUpdateID); } context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}"); } else { // reverse ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(@"{""StatusAcks"": """ + HttpUtility.HtmlEncode(statcomup.StatusCommentAcknowledgementsOptions) + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) && !string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) ) { mu = Membership.GetUser(); if (mu == null) return; StatusComment statCom = new StatusComment(); statCom.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); statCom.Message = HttpUtility.HtmlEncode(context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]); statCom.StatusUpdateID = statusUpdateID; statCom.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); //statCom.GetStatusCommentMessage(); // ? ignore this duplicate now // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME if (statCom.StatusCommentID == 0) { //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY StatusUpdate suLast = new StatusUpdate(); suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey)); if (suLast.Message.Trim() != statCom.Message.Trim() || (suLast.Message.Trim() == statCom.Message.Trim() && suLast.StatusUpdateID != statCom.StatusUpdateID)) { statCom.Create(); } statup = new StatusUpdate(statusUpdateID); // create a status update notification for the post maker and all commenters StatusUpdateNotification sun = null; if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (sun.StatusUpdateNotificationID == 0) { sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString()); sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.StatusUpdateID = statup.StatusUpdateID; sun.UserAccountID = statup.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.Update(); } SendNotificationEmail(statup.UserAccountID, SiteEnums.ResponseType.C, sun.StatusUpdateID); } StatusComments statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statusUpdateID); foreach (StatusComment sc1 in statComs) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID || Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue; if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.StatusUpdateID = statusUpdateID; sun.UserAccountID = sc1.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.Update(); } } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P" ) { // delete post statup = new StatusUpdate(statusUpdateID); StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID); Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID); StatusComments statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID); foreach (StatusComment sc1 in statComs) { StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(sc1.StatusCommentID); } StatusComments.DeleteStatusComments(statup.StatusUpdateID); statup.Delete(); if (statup.PhotoItemID != null) { PhotoItem pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID)); S3Service s3 = new S3Service(); s3.AccessKeyID = AmazonCloudConfigs.AmazonAccessKey; s3.SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey; if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb); } pitm.Delete(); } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "C" ) { // delete comment StatusComment statCom = new StatusComment( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.status_com_id.ToString()])); StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements(statCom.StatusCommentID); statCom.Delete(); context.Response.Write(@"{""StatusUpdateID"": """ + statCom.StatusUpdateID.ToString() + @"""}"); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()])) { mu = Membership.GetUser(); if (mu == null) return; StatusComments preFilter = new StatusComments(); preFilter.GetAllStatusCommentsForUpdate(statusUpdateID); StatusComments statComs = new StatusComments(); foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusComment su1 in preFilter) { if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)) { statComs.Add(su1); } } statComs.IncludeStartAndEndTags = true; sb = new StringBuilder(100); sb.Append(statComs.ToUnorderdList); context.Response.Write(@"{""StatusComs"": """ + HttpUtility.HtmlEncode(sb.ToString()) + @"""}"); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()])) { int pcount = Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()]); StatusUpdates statups = new StatusUpdates(); pcount = pcount + 10; StatusUpdates preFilter = new StatusUpdates(); preFilter.GetStatusUpdatesPageWise(pcount, 1); StatusUpdates sus = new StatusUpdates(); mu = Membership.GetUser(); foreach (BootBaronLib.AppSpec.DasKlub.BOL.StatusUpdate su1 in preFilter) { if (!BootBaronLib.AppSpec.DasKlub.BOL.BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID)) { statups.Add(su1); } } statups.IncludeStartAndEndTags = false; context.Response.Write(@"{""StatusUpdates"": """ + HttpUtility.HtmlEncode(statups.ToUnorderdList) + @"""}"); } #endregion break; case SiteEnums.QueryStringNames.begin_playlist: #region begin_playlist context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[ SiteEnums.QueryStringNames.playlist.ToString()]))); #endregion break; case SiteEnums.QueryStringNames.menu: #region menu mu = Membership.GetUser(); // menu updates // get count in video room int userCountChat = 0; // get new mail int userMessages = 0; // get new users int unconfirmedUsers = 0; // status notifications int notifications = 0; if (mu != null) { // log off users who are offline UserAccounts uasOffline = new UserAccounts(); uasOffline.GetWhoIsOffline(true); UserAccount offlineUser = null; foreach (UserAccount uaoff1 in uasOffline) { ChatRoomUser cru = new ChatRoomUser(); cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID); if (cru.ChatRoomUserID > 0) { cru.DeleteChatRoomUser(); } offlineUser = new UserAccount(uaoff1.UserAccountID); offlineUser.RemoveCache(); } userCountChat = ChatRoomUsers.GetChattingUserCount(); userMessages = BootBaronLib.AppSpec.DasKlub.BOL.DirectMessages.GetDirectMessagesToUserCount(mu); unconfirmedUsers = BootBaronLib.AppSpec.DasKlub.BOL.UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey)); } // get users online int onlineUsers = UserAccounts.GetOnlineUserCount(); if (mu != null) { notifications = StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser(Convert.ToInt32(mu.ProviderUserKey)); } string timedMessge = string.Format( @"{{""UserCountChat"": ""{0}"", ""UserMessages"": ""{1}"", ""OnlineUsers"": ""{2}"", ""Notifications"": ""{3}"", ""UnconfirmedUsers"": ""{4}""}}",userCountChat,userMessages,onlineUsers,notifications,unconfirmedUsers); context.Response.Write(timedMessge); #endregion break; case SiteEnums.QueryStringNames.random: #region random if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write(Video.GetRandomJSON( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else { context.Response.Write(Video.GetRandomJSON()); } #endregion break; case SiteEnums.QueryStringNames.video_playlist: #region video_playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; case SiteEnums.QueryStringNames.video: #region video Video vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]); VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress); context.Response.Write(Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()])); #endregion break; case SiteEnums.QueryStringNames.begindate: #region begindate //string[] dates = HttpUtility.UrlDecode( // context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()] // ).Split('G'); DateTime dtBegin = Convert.ToDateTime(context.Request.QueryString[SiteEnums.QueryStringNames.begindate.ToString()]); dtBegin = new DateTime(dtBegin.Year, dtBegin.Month, 1); DateTime dtEnd = dtBegin.AddMonths(1).AddDays(-1); Events tds = new Events(); tds.GetEventsForLocation( dtBegin, dtEnd, context.Request.QueryString[SiteEnums.QueryStringNames.country_iso.ToString()], context.Request.QueryString[SiteEnums.QueryStringNames.region.ToString()], context.Request.QueryString[SiteEnums.QueryStringNames.city.ToString()]); CalendarItems citms = GetCitms(tds, dtBegin, dtEnd, true); //[ 100, 500, 300, 200, 400 ] sb = new StringBuilder(); sb.Append("["); int processed = 1; foreach (CalendarItem ci1 in citms) { if (processed == citms.Count) { sb.Append(ci1.StartDate.Day); } else { sb.Append(ci1.StartDate.Day); sb.Append(", "); } processed++; } sb.Append("]"); context.Response.Write(sb.ToString()); #endregion break; case SiteEnums.QueryStringNames.playlist: #region playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if (!string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32(context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; default: // ? break; } }
public void ProcessRequest(HttpContext context) { if (string.IsNullOrEmpty(context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()])) return; var ptyc = (SiteEnums.QueryStringNames) Enum.Parse(typeof (SiteEnums.QueryStringNames), context.Request.QueryString[SiteEnums.QueryStringNames.param_type.ToString()]); MembershipUser mu; switch (ptyc) { case SiteEnums.QueryStringNames.status_update: #region status_update string key = context.Request.QueryString[SiteEnums.QueryStringNames.status_update_id.ToString()]; if (string.IsNullOrEmpty(key)) { key = context.Request.QueryString[ SiteEnums.QueryStringNames.most_applauded_status_update_id.ToString()]; } int statusUpdateID = Convert.ToInt32(key); StatusUpdate statup; if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var ack = new Acknowledgement { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), UserAccountID = Convert.ToInt32(mu.ProviderUserKey), AcknowledgementType = Convert.ToChar( context.Request.QueryString[SiteEnums.QueryStringNames.stat_update_rsp.ToString()]), StatusUpdateID = statusUpdateID }; statup = new StatusUpdate(statusUpdateID); if (!Acknowledgement.IsUserAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey))) { ack.Create(); var sun = new StatusUpdateNotification(); if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.A); } if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun.UserAccountID = statup.UserAccountID; SiteEnums.ResponseType rspType; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.Create(); } else { sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType, sun.StatusUpdateID); } context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(statup.StatusAcknowledgements))); } else { // reverse ack.GetAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode(statup.StatusAcknowledgements))); } } else if ( !string.IsNullOrEmpty( context.Request.QueryString[ SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var ack = new StatusCommentAcknowledgement { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), UserAccountID = Convert.ToInt32(mu.ProviderUserKey), AcknowledgementType = Convert.ToChar( context.Request.QueryString[ SiteEnums.QueryStringNames.stat_update_comment_rsp.ToString()]), StatusCommentID = statusUpdateID }; var statcomup = new StatusComment(statusUpdateID); statup = new StatusUpdate(statcomup.StatusUpdateID); if (!StatusCommentAcknowledgement.IsUserCommentAcknowledgement(statcomup.StatusCommentID, Convert.ToInt32( mu.ProviderUserKey))) { ack.Create(); var sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statcomup.UserAccountID, statcomup.StatusUpdateID, ack.AcknowledgementType == Convert.ToChar( SiteEnums.ResponseType.A.ToString()) ? SiteEnums.ResponseType.A : SiteEnums.ResponseType.B); if (Convert.ToInt32(mu.ProviderUserKey) != statcomup.UserAccountID) { sun.UserAccountID = statcomup.UserAccountID; SiteEnums.ResponseType rspType; if (ack.AcknowledgementType == Convert.ToChar(SiteEnums.ResponseType.A.ToString())) { rspType = SiteEnums.ResponseType.A; sun.ResponseType = Convert.ToChar(rspType.ToString()); } else { rspType = SiteEnums.ResponseType.B; sun.ResponseType = Convert.ToChar(rspType.ToString()); } if (sun.StatusUpdateNotificationID == 0) { sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Create(); } else { sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), rspType, sun.StatusUpdateID); } context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode( statcomup.StatusCommentAcknowledgementsOptions))); } else { // reverse ack.GetCommentAcknowledgement(statusUpdateID, Convert.ToInt32(mu.ProviderUserKey)); ack.Delete(); // TODO: DELETE NOTIFICATION context.Response.Write(string.Format(@"{{""StatusAcks"": ""{0}""}}", HttpUtility.HtmlEncode( statcomup.StatusCommentAcknowledgementsOptions))); } } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) && !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]) ) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var statCom = new StatusComment { CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey), Message = HttpUtility.HtmlEncode( context.Request.QueryString[SiteEnums.QueryStringNames.comment_msg.ToString()]), StatusUpdateID = statusUpdateID, UserAccountID = Convert.ToInt32(mu.ProviderUserKey) }; // TODO: CHECK IF THERE IS A RECENT MESSAGE THAT IS THE SAME if (statCom.StatusCommentID != 0) return; //BUG: THERE IS AN EVENT HANDLER THAT HAS QUEUED UP TOO MANY var suLast = new StatusUpdate(); suLast.GetMostRecentUserStatus(Convert.ToInt32(mu.ProviderUserKey)); if (suLast.Message.Trim() != statCom.Message.Trim() || (suLast.Message.Trim() == statCom.Message.Trim() && suLast.StatusUpdateID != statCom.StatusUpdateID)) { statCom.Create(); } statup = new StatusUpdate(statusUpdateID); // create a status update notification for the post maker and all commenters StatusUpdateNotification sun; if (Convert.ToInt32(mu.ProviderUserKey) != statup.UserAccountID) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (sun.StatusUpdateNotificationID == 0) { sun.ResponseType = Convert.ToChar(SiteEnums.ResponseType.C.ToString()); sun.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.IsRead = false; sun.StatusUpdateID = statup.StatusUpdateID; sun.UserAccountID = statup.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); sun.Update(); } SendNotificationEmail(statup.UserAccountID, Convert.ToInt32(mu.ProviderUserKey), SiteEnums.ResponseType.C, sun.StatusUpdateID); } var statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statusUpdateID); foreach (StatusComment sc1 in statComs) { sun = new StatusUpdateNotification(); sun.GetStatusUpdateNotificationForUserStatus(statup.UserAccountID, statusUpdateID, SiteEnums.ResponseType.C); if (Convert.ToInt32(mu.ProviderUserKey) == sc1.UserAccountID || Convert.ToInt32(mu.ProviderUserKey) == statup.UserAccountID) continue; if (sun.StatusUpdateNotificationID == 0) { sun.IsRead = false; sun.StatusUpdateID = statusUpdateID; sun.UserAccountID = sc1.UserAccountID; sun.Create(); } else { sun.IsRead = false; sun.Update(); } } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "P" ) { // delete post statup = new StatusUpdate(statusUpdateID); StatusUpdateNotifications.DeleteNotificationsForStatusUpdate(statup.StatusUpdateID); Acknowledgements.DeleteStatusAcknowledgements(statup.StatusUpdateID); var statComs = new StatusComments(); statComs.GetAllStatusCommentsForUpdate(statup.StatusUpdateID); foreach (StatusComment sc1 in statComs) { StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements( sc1.StatusCommentID); } StatusComments.DeleteStatusComments(statup.StatusUpdateID); statup.Delete(); if (statup.PhotoItemID != null) { var pitm = new PhotoItem(Convert.ToInt32(statup.PhotoItemID)); var s3 = new S3Service { AccessKeyID = AmazonCloudConfigs.AmazonAccessKey, SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey }; if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathRaw); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathStandard); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, pitm.FilePathThumb); } pitm.Delete(); } context.Response.Write(@"{""StatusAcks"": """ + @"""}"); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()]) && context.Request.QueryString[SiteEnums.QueryStringNames.act_type.ToString()] == "C" ) { // delete comment var statCom = new StatusComment( Convert.ToInt32( context.Request.QueryString[ SiteEnums.QueryStringNames.status_com_id.ToString()])); StatusCommentAcknowledgements.DeleteStatusCommentAcknowledgements( statCom.StatusCommentID); statCom.Delete(); context.Response.Write(string.Format(@"{{""StatusUpdateID"": ""{0}""}}", statCom.StatusUpdateID)); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.all_comments.ToString()])) { mu = MembershipWrapper.GetUser(); if (mu == null) return; var preFilter = new StatusComments(); preFilter.GetAllStatusCommentsForUpdate(statusUpdateID); var statComs = new StatusComments(); statComs.AddRange( preFilter.Where( su1 => !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))); statComs.IncludeStartAndEndTags = true; var sb = new StringBuilder(100); sb.Append(statComs.ToUnorderdList); context.Response.Write(string.Format(@"{{""StatusComs"": ""{0}""}}", HttpUtility.HtmlEncode(sb.ToString()))); } else if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.comment_page.ToString()])) { int pcount = Convert.ToInt32( context.Request.QueryString[ SiteEnums.QueryStringNames.comment_page.ToString()]); var statups = new StatusUpdates(); pcount = pcount + 10; var preFilter = new StatusUpdates(); preFilter.GetStatusUpdatesPageWise(pcount, 1); mu = MembershipWrapper.GetUser(); statups.AddRange( preFilter.Where( su1 => mu != null && !BlockedUser.IsBlockingUser(Convert.ToInt32(mu.ProviderUserKey), su1.UserAccountID))); statups.IncludeStartAndEndTags = false; context.Response.Write(string.Format(@"{{""StatusUpdates"": ""{0}""}}", HttpUtility.HtmlEncode(statups.ToUnorderdList))); } #endregion break; case SiteEnums.QueryStringNames.begin_playlist: #region begin_playlist context.Response.Write( PlaylistVideo.GetFirstVideo(Convert.ToInt32(context.Request.QueryString[ SiteEnums.QueryStringNames.playlist.ToString()]))); #endregion break; case SiteEnums.QueryStringNames.menu: #region menu mu = MembershipWrapper.GetUser(); int userCountChat = 0; int userMessages = 0; int unconfirmedUsers = 0; int notifications = 0; if (mu != null) { // log off users who are offline var uasOffline = new UserAccounts(); uasOffline.GetWhoIsOffline(true); foreach (UserAccount uaoff1 in uasOffline) { var cru = new ChatRoomUser(); cru.GetChatRoomUserByUserAccountID(uaoff1.UserAccountID); if (cru.ChatRoomUserID > 0) { cru.DeleteChatRoomUser(); } var offlineUser = new UserAccount(uaoff1.UserAccountID); offlineUser.RemoveCache(); } userCountChat = ChatRoomUsers.GetChattingUserCount(); userMessages = DirectMessages.GetDirectMessagesToUserCount(mu); unconfirmedUsers = UserConnections.GetCountUnconfirmedConnections(Convert.ToInt32(mu.ProviderUserKey)); } // get users online int onlineUsers = UserAccounts.GetOnlineUserCount(); if (mu != null) { notifications = StatusUpdateNotifications.GetStatusUpdateNotificationCountForUser( Convert.ToInt32(mu.ProviderUserKey)); } string timedMessge = string.Format( @"{{""UserCountChat"": ""{0}"", ""UserMessages"": ""{1}"", ""OnlineUsers"": ""{2}"", ""Notifications"": ""{3}"", ""UnconfirmedUsers"": ""{4}""}}", userCountChat, userMessages, onlineUsers, notifications, unconfirmedUsers); context.Response.Write(timedMessge); #endregion break; case SiteEnums.QueryStringNames.random: #region random if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write(Video.GetRandomJSON( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else { context.Response.Write(Video.GetRandomJSON()); } #endregion break; case SiteEnums.QueryStringNames.video_playlist: #region video_playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; case SiteEnums.QueryStringNames.video: #region video var vid = new Video("YT", context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()]); VideoLog.AddVideoLog(vid.VideoID, context.Request.UserHostAddress); context.Response.Write( Video.GetVideoJSON(context.Request.QueryString[SiteEnums.QueryStringNames.vid.ToString()])); #endregion break; case SiteEnums.QueryStringNames.playlist: #region playlist if (!string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])) { context.Response.Write( PlaylistVideo.GetNextVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]), context.Request.QueryString[SiteEnums.QueryStringNames.currentvidid.ToString()])); } else if ( !string.IsNullOrEmpty( context.Request.QueryString[SiteEnums.QueryStringNames.begin_playlist.ToString()])) { context.Response.Write( PlaylistVideo.GetFirstVideo( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]))); } else { context.Response.Write( PlaylistVideo.CurrentVideoInPlaylist( Convert.ToInt32( context.Request.QueryString[SiteEnums.QueryStringNames.playlist.ToString()]) )); } #endregion break; } }
public ActionResult StatusDelete(NameValueCollection nvc) { if (Request.Form["delete_status_id"] != null) { StatusUpdate su = new StatusUpdate( Convert.ToInt32(Request.Form["delete_status_id"]) ); // delete all acknowledgements for status Acknowledgements.DeleteStatusAcknowledgements(su.StatusUpdateID); su.Delete(); } else if (Request.Form["status_update_id_beat"] != null || Request.Form["status_update_id_applaud"] != null) { mu = Membership.GetUser(); Acknowledgement ack = new Acknowledgement(); ack.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ack.UserAccountID = Convert.ToInt32(mu.ProviderUserKey); if (Request.Form["status_update_id_beat"] != null) { ack.AcknowledgementType = 'B'; ack.StatusUpdateID = Convert.ToInt32(Request.Form["status_update_id_beat"]); } else if (Request.Form["status_update_id_applaud"] != null) { ack.AcknowledgementType = 'A'; ack.StatusUpdateID = Convert.ToInt32(Request.Form["status_update_id_applaud"]); } if (!Acknowledgement.IsUserAcknowledgement(ack.StatusUpdateID, ack.UserAccountID)) { ack.Create(); } } return RedirectToAction("Home"); }
// Delegate handles the message available event static void connector_MessageAvailable(object sender, UnsolicitedDataEventArgs e) { // Cast connector WcfServerConnector connector = sender as WcfServerConnector; connector.InvalidResponse += new EventHandler<MessageEventArgs>(connector_InvalidResponse); // Receive the structure WcfReceiveResult rcvResult = connector.Receive() as WcfReceiveResult; if (rcvResult.Structure != null) Console.WriteLine(rcvResult.Structure.GetType().Name); // Prepare acknowledgement structure Acknowledgement acknowledgement = new Acknowledgement(); // Assign the correlation acknowledgement.TargetMessage = new TargetMessage( (rcvResult.Structure as IIdentifiable).Id ); // Determine the deserialization outcome if (rcvResult.Code != ResultCode.Accepted && rcvResult.Code != ResultCode.AcceptedNonConformant) // There were problems parsing the request message acknowledgement.TypeCode = AcknowledgementType.AcceptAcknowledgementCommitError; else // Message is all good acknowledgement.TypeCode = AcknowledgementType.AcceptAcknowledgementCommitAccept; // Append all details foreach (IResultDetail dtl in rcvResult.Details) { AcknowledgementDetail detail = new AcknowledgementDetail( AcknowledgementDetailType.Information, AcknowledgementDetailCode.SyntaxError, dtl.Message, new SET<ST>((ST)dtl.Location) ); acknowledgement.AcknowledgementDetail.Add(detail); } // Create a response MCCI_IN000002CA response = new MCCI_IN000002CA( new II(Guid.NewGuid()), DateTime.Now, ResponseMode.Immediate, MCCI_IN000002CA.GetInteractionId(), MCCI_IN000002CA.GetProfileId(), ProcessingID.Production, AcknowledgementCondition.Never, new Receiver( new Device2( new II() ) ), new Sender( new Device1( new II("1.1.1.1.1") ) ), acknowledgement ); // Send the result connector.Send(response, rcvResult); }