Skip to content

Commit

Permalink
Merge pull request #23 from dinfcll/dv_np_CommentePhotoLienUtil
Browse files Browse the repository at this point in the history
Dv np commente photo lien util
  • Loading branch information
xxdomxx committed Nov 21, 2014
2 parents 73bb670 + e10490a commit 2189762
Show file tree
Hide file tree
Showing 56 changed files with 357 additions and 165 deletions.
Binary file modified PhotoFun.suo
Binary file not shown.
59 changes: 59 additions & 0 deletions PhotoFun/Content/MonCSS.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,62 @@
{
padding-left:2%;
}

.boutonediter
{
float:right;
position:absolute;
right:2%;
bottom:3%;
}

.btnchoisirfich
{
border: 1px solid #e2e2e2;
background: #fff;
color: #333;
font-size: 1.2em;
margin: 5px 0 6px 0;
padding: 5px;
width: 450px;
}

.menucotegauche
{
padding-top:60px;
position:fixed;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}

.menucotegauche > li {
position: relative;
display: block;
color:#777;
}
.menucotegauche > li > a {
position: relative;
display: block;
padding: 10px 15px;
color:#777;
}
.menucotegauche > li > a:hover,
.menucotegauche > li > a:focus {
text-decoration: none;
color:#fff
}

.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 2%;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
background-color: #101010;
border-right: 1px solid #eee;
}
64 changes: 0 additions & 64 deletions PhotoFun/Content/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -6302,75 +6302,11 @@ textarea {
width: auto;
}

input[type="submit"],
input[type="button"],
button {
background-color: #d3dce0;
border: 1px solid #787878;
cursor: pointer;
font-size: 1.2em;
font-weight: 600;
padding: 7px;
margin-right: 8px;
width: auto;
}

td input[type="submit"],
td input[type="button"],
td button {
font-size: 1em;
padding: 4px;
margin-right: 4px;
}
.btnchoisirfich
{
border: 1px solid #e2e2e2;
background: #fff;
color: #333;
font-size: 1.2em;
margin: 5px 0 6px 0;
padding: 5px;
width: 450px;
}

.menucotegauche
{
padding-top:60px;
position:fixed;
padding-left: 0;
margin-bottom: 0;
list-style: none;
background-color:Lime;
}

.menucotegauche > li {
position: relative;
display: block;
color:#777;
}
.menucotegauche > li > a {
position: relative;
display: block;
padding: 10px 15px;
color:#777;
}
.menucotegauche > li > a:hover,
.menucotegauche > li > a:focus {
text-decoration: none;
color:#fff
}

.sidebar {
position: fixed;
top: 51px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
background-color: #101010;
border-right: 1px solid #eee;
}

61 changes: 61 additions & 0 deletions PhotoFun/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,36 @@ public ActionResult PhotoUtil(string image, string actionAFaire,string nom)
}
}
}
else
{
if (image != null && actionAFaire == "EDIT")
{
return RedirectToAction("EditCommentaireUtil", "Account", new { image = image });
}
}
}
return RedirectToAction("Erreur", "Home");
}

public ActionResult EditCommentaireUtil(string image)
{
string commentaire;
PhotoFunBD photoFunBD = new PhotoFunBD();
commentaire=photoFunBD.ExtraireCommentaireSelonPhoto(image);
ViewData["commentaire"] = commentaire;
ViewData["image"] = image;
return View();
}

[HttpPost]
public ActionResult EditCommentaireUtil(string Image, string Commentaire)
{
PhotoFunBD photoFunBD=new PhotoFunBD();
string nouveaucommentaire = Commentaire;
string image= Image;
if (photoFunBD.MettreAJourLeCommentaireDeLaPhoto(nouveaucommentaire, image))
{
return RedirectToAction("PhotoUtil", "Account", new { nom = User.Identity.Name });
}
return RedirectToAction("Erreur", "Home");
}
Expand All @@ -154,6 +184,37 @@ public ActionResult Profil()
return View();
}

[AllowAnonymous]
public ActionResult ProfilUtil(string nomUtil)
{
var photoFunBD = new PhotoFunBD();
var profilModel = new ProfilModel();
var retour = new List<string>();
int nbAbonnement;
if (photoFunBD.ExtraireUtil(nomUtil, out retour))
{
if (retour.Count > 0)
{
profilModel.IdUtilRechercher = nomUtil;

if (photoFunBD.CompteNbAbonnement(profilModel, out nbAbonnement))
{
profilModel.NbAbonnement = nbAbonnement;
}
profilModel.Abonner = photoFunBD.VerifAbonnement(profilModel.IdUtilRechercher, User.Identity.Name);
ViewData["Rechercher"] = profilModel;
}
else
{
profilModel.Abonner = false;
profilModel.IdUtilRechercher = "Utilisateur Inexistant";
profilModel.NbAbonnement = 0;
ViewData["Rechercher"] = profilModel;
}
}
return View();
}

[AllowAnonymous]
[HttpPost]
public ActionResult ProfilUtil()
Expand Down
74 changes: 73 additions & 1 deletion PhotoFun/Models/PhotoFunBD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace PhotoFun.Models
public class PhotoFunBD
{
private const string cs = "Data Source=EQUIPE-01\\SQLEXPRESS ;Initial Catalog=tempdb;Integrated Security=True";

public bool InsererUtil(RegisterModel rm)
{
using (var conn = new SqlConnection(cs))
Expand Down Expand Up @@ -79,6 +80,51 @@ public bool ExtraireUtil(string IDUtil, out List<string> NomUtil)
}
}

public bool MettreAJourLeCommentaireDeLaPhoto(string commentaire, string photo)
{
using (var conn = new SqlConnection(cs))
{
bool resultat;
try
{
conn.Open();
var scModifier= new SqlCommand("Update Photos set Commentaire='"+commentaire+"' where Image='"+photo+"';", conn);
scModifier.ExecuteNonQuery();
conn.Close();
resultat = true;
}
catch
{
resultat = false;
}
return resultat;
}
}

public string ExtraireCommentaireSelonPhoto(string image)
{
using (var conn = new SqlConnection(cs))
{
string commentaire = "";
try
{
conn.Open();
var scExtraireCommentaireSelonPhoto = new SqlCommand("Select Commentaire from Photos where Image='" + image + "';", conn);
var sdr = scExtraireCommentaireSelonPhoto.ExecuteReader();
while (sdr.Read())
{
commentaire=ReadSingleRow(sdr);
}
sdr.Close();
conn.Close();
}
catch
{
}
return commentaire;
}
}

public bool MettreAJourUtil(LocalPasswordModel lpm, string usager)
{
using (var conn = new SqlConnection(cs))
Expand Down Expand Up @@ -169,6 +215,30 @@ public bool ExtrairePhotoSelonUtil(string NomUtil,out List<string> lstimage)
}
}

public string ExtraireUtilSelonPhoto(string image)
{
using (var conn = new SqlConnection(cs))
{
string nomUtil = "";
try
{
conn.Open();
var scExtraireUtilSelonPhoto = new SqlCommand("Select IDUtil from Photos where Image='" + image + "';", conn);
var sdr = scExtraireUtilSelonPhoto.ExecuteReader();
while (sdr.Read())
{
nomUtil=ReadSingleRow(sdr);
}
sdr.Close();
conn.Close();
}
catch
{
}
return nomUtil;
}
}

public bool ExtrairePhotoSelonCategorie(string Categorie, out List<string> lstimage)
{
lstimage = new List<string>();
Expand Down Expand Up @@ -363,6 +433,7 @@ public bool InsererDonneesProfil(ProfilModel pm)
return resultat;
}
}

public bool EnleveTousLesLiaisonsAvecLesUtils(string nomPhoto)
{
using(var conn=new SqlConnection(cs))
Expand Down Expand Up @@ -467,6 +538,7 @@ public bool VerifAbonnement(string pm, string UtilConnecter)
return resultat;
}
}

public bool VerifLiaisonPhotoUtil(string nomUtil, string nomPhoto)
{
using (var conn = new SqlConnection(cs))
Expand Down Expand Up @@ -501,7 +573,6 @@ public bool VerifLiaisonPhotoUtil(string nomUtil, string nomPhoto)
}
}


public bool SupprimerRelAbonnement(string UtilAbonner, string UtilConnecter)
{
using (var conn = new SqlConnection(cs))
Expand All @@ -523,6 +594,7 @@ public bool SupprimerRelAbonnement(string UtilAbonner, string UtilConnecter)
return resultat;
}
}

public bool AjoutRelationUtilPhoto(string nomUtil, string nomPhoto)
{
using (var conn = new SqlConnection(cs))
Expand Down
2 changes: 2 additions & 0 deletions PhotoFun/PhotoFun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
<Content Include="Scripts\knockout-2.1.0.debug.js" />
<Content Include="Scripts\knockout-2.1.0.js" />
<Content Include="Scripts\modernizr-2.5.3.js" />
<Content Include="Scripts\MonSite.js" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
Expand Down Expand Up @@ -311,6 +312,7 @@
<Content Include="Views\Home\_PasPhotoCategorie.cshtml" />
<Content Include="Views\Account\ProfilUtil.cshtml" />
<Content Include="Views\Home\RetourneLaVueSelonCategorie.cshtml" />
<Content Include="Views\Account\EditCommentaireUtil.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
14 changes: 14 additions & 0 deletions PhotoFun/Scripts/MonSite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$("button.fullscreen").click(function () {
var imgSrc = $(this).siblings('img').attr("src");
var nomUtilisateur = $(this).siblings('span.nomUtil').attr("item");
var commentaire = $(this).siblings('span.commentaire').attr("item");
var href="/Account/ProfilUtil?nomUtil="+nomUtilisateur;
$("#PhotoModal img").attr("src", imgSrc);
$("#nomUtil").attr("href", href);
document.getElementById('nomUtil').innerHTML = nomUtilisateur;
document.getElementById('commentaire').innerHTML = commentaire;
});
function reste(texte) {
var restants = 200 - texte.length;
document.getElementById('caracteres').innerHTML = restants;
};
25 changes: 25 additions & 0 deletions PhotoFun/Views/Account/EditCommentaireUtil.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@{
ViewBag.Title = "Éditez votre commentaire";
var commentaire = ViewData["commentaire"] as string;
var image = ViewData["image"] as string;
}

<div class="page-header">
<h2>@ViewBag.Title</h2>
</div>
<div>
<img src="@image" class="img-thumbnail" alt="Image inaccessible" width="65%" />
<div>
@using (Html.BeginForm("EditCommentaireUtil", "Account", FormMethod.Post))
{
<h3>Commentaires</h3>
<br/>
<textarea autofocus onkeyup = "reste(this.value);" maxlength = "200" rows="5" cols="50" name="Commentaire">@commentaire</textarea>
@Html.Hidden("Image", image)
<br/>
<span id="caracteres">200</span><span> caractères restants</span>
<br/>
<input class="btn btn-lg btn-info" type="submit" value="Appliquer"/>
}
</div>
</div>
Loading

0 comments on commit 2189762

Please sign in to comment.