Scenario
This article explains how to display the user Skype status in the user profile in a MVC application. The administrator in a site wants to view the list of users with his/her Skype status and also wants to chat/call by clicking on the Skype status in the user profile.
Step 1
Create a new project named UsersSkypeStatusInMVC and choose the template MVC. It then creates an MVC template project.
Step 2
Add a Controller named AdminController with the following procedure.
Step 3
In this step, Add a Model named "UserModel" using the following procedure.
Step 4
This step, replace the existing code in the "AdminController.cs" file with the following code.
About Code
This step, add a view for the UserProfiles Action controller method by the following procedure:
This step replaces the existing code in the "UserProfiles.csthtml" file design with the following code.
About the Design
This step helps you about Skype Status URL information and other details. To display the Skype status of any user, you have to request the URL format as follows.
The format of the URL is: http://mystatus.skype.com/{SIZE OF ICON}/{SKYPE ID}
{SIZE OF ICON}: It indicates to display the size of the icon based on user Skype status.
For example: smallicon, mediumicon
{SKYPE ID}: It indicates the Skype Id of the user.
For example: ramchand.repalle
So, the example of the Skype status URL is http://mystatus.skype.com/mediumicon/ramchand.repalle.
You can get the status of the user by just clicking on the previously shown URL.
Step 8
Add a new folder named “Images” with sample images to the “UsersSkypeStatusInMVC” project. It helps display the sample image for the profile picture as mentioned in the "GetUsers()" method in AdminController.
Step 9
Now, build the application (F6), then run (hit F5) an application and navigate to the following URL: (http://localhost:57882/Admin/UserProfiles).
As in the preceding screenshots by clicking on the (Skype) icon it displays a popup to launch the application in Skype. You just click on that then it would open a Skype user window.
The Skype status images are displayed as described below.
The discussed project source code can be downloaded from the link Source Code.
I hope this article helps you to display the Skype user status with the user profile details in a MVC application.
This article explains how to display the user Skype status in the user profile in a MVC application. The administrator in a site wants to view the list of users with his/her Skype status and also wants to chat/call by clicking on the Skype status in the user profile.
Prerequisites
To
display the Skype status in a public site, the Skype user must check
(select) the privacy setting "Allow my online status to be shown on the
Web". You can go to the settings by navigating from the Skype menu
Privacy settings and check the "Allow my online status to be shown on
the Web" as shown in the following screenshot.
Implementation
Step 1
Create a new project named UsersSkypeStatusInMVC and choose the template MVC. It then creates an MVC template project.
Step 2
Add a Controller named AdminController with the following procedure.
- Right-click on the "Controllers" folder and select the Add option and click on the "Controller" link.
- It opens a pop-up and then select the option MVC 5 Controller – Empty and then click on the "Add" button.
- Again, it opens a popup and then provide the name as AdminController and click on the "Add" button.
Step 3
In this step, Add a Model named "UserModel" using the following procedure.
- Right-click on the "Models" folder and select the "Add" option and click on the "Class...".
- It opens a pop-up and then enter the name as "UserModel.cs" and click on the Add button.
namespace UsersSkypeStatusInMVC.Models { ////// User Model /// public class UserModel { public int UserId { get; set; } public string Name { get; set; } public string Email { get; set; } public string SkypeId { get; set; } public string ProfileImagePath { get; set; } } }
Step 4
This step, replace the existing code in the "AdminController.cs" file with the following code.
using System.Collections.Generic; using System.Web.Mvc; using UsersSkypeStatusInMVC.Models; namespace UsersSkypeStatusInMVC.Controllers { public class AdminController : Controller { // GET: UsersProfile public ActionResult UserProfiles() { ListusersList = GetUsers(); return View(usersList); } /// /// Get the list of sample users /// ///User List private ListGetUsers() { var usersList = new List { new UserModel { UserId = 1, Name="Ramchand", Email = "ram@abc.com", SkypeId = "ramchand.repalle", // Skype Id ProfileImagePath = "Ramchand.jpg" }, new UserModel { UserId = 2, Name="Abc", Email = "chand@abc.com", SkypeId = "abctest",// Skype Id ProfileImagePath = "abc.jpg" }, new UserModel { UserId = 3, Name="def", Email = "def@abc.com", SkypeId = "ram",// Skype Id ProfileImagePath = "def.jpg" } }; return usersList; } } }
About Code
- The GetUsers() method will provide a sample list of users.
- You will call that method in the UserProfiles Action Result method and then send that list of users to the view.
This step, add a view for the UserProfiles Action controller method by the following procedure:
- Right-click on the View() method in the UsersProfile Action method and click on "Add View".
- Enter the view name as "UserProfiles" and then click on the "Add" button.
This step replaces the existing code in the "UserProfiles.csthtml" file design with the following code.
@model IEnumerable@{ ViewBag.Title = "User Profiles"; } User Profiles
@foreach (var item in Model) { var skypeId = @Html.DisplayFor(modelItem => item.SkypeId); var profileImg = "../../Images/" + @Html.DisplayFor(modelItem => item.ProfileImagePath);}@Html.DisplayFor(modelItem => item.UserId)
@Html.DisplayFor(modelItem => item.Name)
@Html.DisplayFor(modelItem => item.Email)
About the Design
- Added a namespace to get the list of users.
- CSS styles are defined.
- A foreach loop helps to display the list of users with respective details.
- Skype:
{SKYPE ID}?chat: This is the href tag, you can use to chat the Skype by
clicking on that. For example: skype:ramchand.repalle?chat
- Skype:
{SKYPE ID}?call: This is the href tag, you can use to call the Skype by
clicking on that. For example: skype:ramchand.repalle?call
- JavaScript function SkypeUserStatus helps to assign the Skype status image.
- SetInterVal has been used to call the SkypeUserStatus function periodically to get the current Skype status of a user.
This step helps you about Skype Status URL information and other details. To display the Skype status of any user, you have to request the URL format as follows.
The format of the URL is: http://mystatus.skype.com/{SIZE OF ICON}/{SKYPE ID}
{SIZE OF ICON}: It indicates to display the size of the icon based on user Skype status.
For example: smallicon, mediumicon
{SKYPE ID}: It indicates the Skype Id of the user.
For example: ramchand.repalle
So, the example of the Skype status URL is http://mystatus.skype.com/mediumicon/ramchand.repalle.
You can get the status of the user by just clicking on the previously shown URL.
Step 8
Add a new folder named “Images” with sample images to the “UsersSkypeStatusInMVC” project. It helps display the sample image for the profile picture as mentioned in the "GetUsers()" method in AdminController.
Step 9
Now, build the application (F6), then run (hit F5) an application and navigate to the following URL: (http://localhost:57882/Admin/UserProfiles).
As in the preceding screenshots by clicking on the (Skype) icon it displays a popup to launch the application in Skype. You just click on that then it would open a Skype user window.
The Skype status images are displayed as described below.
The discussed project source code can be downloaded from the link Source Code.
Conclusion
I hope this article helps you to display the Skype user status with the user profile details in a MVC application.
Hey there, You’ve done an excellent job. I will definitely digg it and personally suggest to my friends. I’m sure they will be benefited from this web site. Best of luck for the next! Please visit my web site whatsmyhousevalue.co.nz. Best free property appraisal service provider.
ReplyDelete