From b48f6c56aa025d709fc74af1e1f1be596947ce40 Mon Sep 17 00:00:00 2001 From: Enmanuel Toribio Date: Thu, 8 Sep 2016 11:57:11 -0800 Subject: [PATCH] Removed dislikes buttons (#507) * Bump version to 0.5.0.0 * Replace table jobOpportunityLike (#506) * Removed the buttons for dislikes --- .gitignore | 3 + .../EmpleoDotNet.AppServices.csproj | 2 - .../IJobOpportunityLikeService.cs | 16 --- .../IJobOpportunityService.cs | 1 + .../JobOpportunityLikeService.cs | 32 ----- .../JobOpportunityService.cs | 10 +- EmpleoDotNet.Core/Domain/JobOpportunity.cs | 11 +- .../Domain/JobOpportunityLike.cs | 25 ---- EmpleoDotNet.Core/EmpleoDotNet.Core.csproj | 1 - EmpleoDotNet.Data/EmpleadoContext.cs | 1 - EmpleoDotNet.Data/EmpleoDotNet.Data.csproj | 7 + ...eTableForLikeAndDislikeColumns.Designer.cs | 29 ++++ ...tunityLikeTableForLikeAndDislikeColumns.cs | 36 +++++ ...nityLikeTableForLikeAndDislikeColumns.resx | 126 ++++++++++++++++++ .../IJobOpportunityLikeRepository.cs | 10 -- .../EmpleoDotNet.Repository.csproj | 2 - .../JobOpportunityLikeRepository.cs | 23 ---- .../JobOpportunityRepository.cs | 10 +- .../UserProfileRepository.cs | 4 +- .../Services/Twitter/TwitterServiceTests.cs | 2 +- .../JobOpportunityControllerTest.cs | 2 +- EmpleoDotNet/App_Start/EmpleadoModule.cs | 2 - .../Controllers/JobOpportunityController.cs | 35 ++--- EmpleoDotNet/EmpleoDotNet.csproj | 1 - EmpleoDotNet/Properties/AssemblyInfo.cs | 4 +- .../JobOpportunityLikeViewModel.cs | 12 -- .../Views/JobOpportunity/Detail.cshtml | 7 +- .../Views/Shared/_JobListPartial.cshtml | 7 +- 28 files changed, 245 insertions(+), 176 deletions(-) delete mode 100644 EmpleoDotNet.AppServices/IJobOpportunityLikeService.cs delete mode 100644 EmpleoDotNet.AppServices/JobOpportunityLikeService.cs delete mode 100644 EmpleoDotNet.Core/Domain/JobOpportunityLike.cs create mode 100644 EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.Designer.cs create mode 100644 EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs create mode 100644 EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.resx delete mode 100644 EmpleoDotNet.Repository/Contracts/IJobOpportunityLikeRepository.cs delete mode 100644 EmpleoDotNet.Repository/JobOpportunityLikeRepository.cs delete mode 100644 EmpleoDotNet/ViewModel/JobOpportunityLike/JobOpportunityLikeViewModel.cs diff --git a/.gitignore b/.gitignore index 8090c308..20f73707 100644 --- a/.gitignore +++ b/.gitignore @@ -183,3 +183,6 @@ EmpleoDotNet.sln.ide #Azure publish profile *.pubxml *.tss + +#Xamarin components +*/Components/* \ No newline at end of file diff --git a/EmpleoDotNet.AppServices/EmpleoDotNet.AppServices.csproj b/EmpleoDotNet.AppServices/EmpleoDotNet.AppServices.csproj index 3388486c..c68b8331 100644 --- a/EmpleoDotNet.AppServices/EmpleoDotNet.AppServices.csproj +++ b/EmpleoDotNet.AppServices/EmpleoDotNet.AppServices.csproj @@ -80,11 +80,9 @@ - - diff --git a/EmpleoDotNet.AppServices/IJobOpportunityLikeService.cs b/EmpleoDotNet.AppServices/IJobOpportunityLikeService.cs deleted file mode 100644 index d43dae14..00000000 --- a/EmpleoDotNet.AppServices/IJobOpportunityLikeService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EmpleoDotNet.Core.Domain; - -namespace EmpleoDotNet.AppServices -{ - public interface IJobOpportunityLikeService - { - void CreateNewLike(JobOpportunityLike jopOpportunityLike); - - List GetLikesByJobOpportunityId(int jobOpportunityId); - } -} diff --git a/EmpleoDotNet.AppServices/IJobOpportunityService.cs b/EmpleoDotNet.AppServices/IJobOpportunityService.cs index 742f5970..7b54aef8 100644 --- a/EmpleoDotNet.AppServices/IJobOpportunityService.cs +++ b/EmpleoDotNet.AppServices/IJobOpportunityService.cs @@ -17,5 +17,6 @@ public interface IJobOpportunityService JobOpportunity GetJobOpportunityById(int? id); List GetMainJobCategoriesCount(); bool JobExists(int id); + void CreateNewReaction(int jobOpportunityId, bool like); } } \ No newline at end of file diff --git a/EmpleoDotNet.AppServices/JobOpportunityLikeService.cs b/EmpleoDotNet.AppServices/JobOpportunityLikeService.cs deleted file mode 100644 index bccc7da7..00000000 --- a/EmpleoDotNet.AppServices/JobOpportunityLikeService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EmpleoDotNet.Core.Domain; -using EmpleoDotNet.Repository; -using EmpleoDotNet.Repository.Contracts; - -namespace EmpleoDotNet.AppServices -{ - public class JobOpportunityLikeService : IJobOpportunityLikeService - { - private readonly IJobOpportunityLikeRepository _jobOpportunityLikeRepository; - - public JobOpportunityLikeService(IJobOpportunityLikeRepository jobOpportunityLikeRepository) - { - _jobOpportunityLikeRepository = jobOpportunityLikeRepository; - } - - public void CreateNewLike(JobOpportunityLike jopOpportunityLike) - { - _jobOpportunityLikeRepository.Add(jopOpportunityLike); - _jobOpportunityLikeRepository.SaveChanges(); - } - - public List GetLikesByJobOpportunityId(int jobOpportunityId) - { - return _jobOpportunityLikeRepository.GetLikesByJobOpportunityId(jobOpportunityId); - } - } -} diff --git a/EmpleoDotNet.AppServices/JobOpportunityService.cs b/EmpleoDotNet.AppServices/JobOpportunityService.cs index 35432c7b..7cd2d791 100644 --- a/EmpleoDotNet.AppServices/JobOpportunityService.cs +++ b/EmpleoDotNet.AppServices/JobOpportunityService.cs @@ -119,6 +119,15 @@ public bool JobExists(int id) return _jobOpportunityRepository.JobExists(id); } + public void CreateNewReaction(int jobOpportunityId, bool like) + { + var job = _jobOpportunityRepository.GetJobOpportunityById(jobOpportunityId); + if (job == null) return; + if (like) job.Likes++; + else job.DisLikes++; + _jobOpportunityRepository.SaveChanges(); + } + public JobOpportunityService( IJobOpportunityRepository jobOpportunityRepository, IUserProfileRepository userProfileRepository @@ -127,7 +136,6 @@ IUserProfileRepository userProfileRepository _jobOpportunityRepository = jobOpportunityRepository; _userProfileRepository = userProfileRepository; } - private readonly IJobOpportunityRepository _jobOpportunityRepository; private readonly IUserProfileRepository _userProfileRepository; } diff --git a/EmpleoDotNet.Core/Domain/JobOpportunity.cs b/EmpleoDotNet.Core/Domain/JobOpportunity.cs index d143313c..ddca9d85 100644 --- a/EmpleoDotNet.Core/Domain/JobOpportunity.cs +++ b/EmpleoDotNet.Core/Domain/JobOpportunity.cs @@ -65,6 +65,16 @@ public class JobOpportunity : EntityBase /// public int ViewCount { get; set; } + /// + /// Contador de likes realizados a una publicación + /// + public int Likes { get; set; } + + /// + /// Contador de dislikes realizados a una publicación + /// + public int DisLikes { get; set; } + /// /// Especifica si el empleo es Tiempo Completo, Independiente, etc. /// @@ -107,7 +117,6 @@ public class JobOpportunity : EntityBase public Location Location { get; set; } - public List JobOpportunityLikes { get; set; } #endregion } diff --git a/EmpleoDotNet.Core/Domain/JobOpportunityLike.cs b/EmpleoDotNet.Core/Domain/JobOpportunityLike.cs deleted file mode 100644 index 682ca13e..00000000 --- a/EmpleoDotNet.Core/Domain/JobOpportunityLike.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EmpleoDotNet.Core.Domain -{ - public class JobOpportunityLike : EntityBase - { - #region Property - - public bool Like { get; set; } - - public int JobOpportunityId { get; set; } - - #endregion - - #region Navegation Properties - - public JobOpportunity JobOpportunity { get; set; } - - #endregion - } -} diff --git a/EmpleoDotNet.Core/EmpleoDotNet.Core.csproj b/EmpleoDotNet.Core/EmpleoDotNet.Core.csproj index 840670e1..1a5e8217 100644 --- a/EmpleoDotNet.Core/EmpleoDotNet.Core.csproj +++ b/EmpleoDotNet.Core/EmpleoDotNet.Core.csproj @@ -45,7 +45,6 @@ - diff --git a/EmpleoDotNet.Data/EmpleadoContext.cs b/EmpleoDotNet.Data/EmpleadoContext.cs index e75d6aeb..de863ee4 100644 --- a/EmpleoDotNet.Data/EmpleadoContext.cs +++ b/EmpleoDotNet.Data/EmpleadoContext.cs @@ -27,7 +27,6 @@ public EmpleadoContext() public DbSet JobOpportunityLocation { get; set; } public DbSet Locations { get; set; } public DbSet UserProfile { get; set; } - public DbSet JobOpportunityLikes { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { diff --git a/EmpleoDotNet.Data/EmpleoDotNet.Data.csproj b/EmpleoDotNet.Data/EmpleoDotNet.Data.csproj index b10e10c5..5f6473c6 100644 --- a/EmpleoDotNet.Data/EmpleoDotNet.Data.csproj +++ b/EmpleoDotNet.Data/EmpleoDotNet.Data.csproj @@ -133,6 +133,10 @@ 201608010547100_AddIsHiddenColumn.cs + + + 201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs + @@ -192,6 +196,9 @@ 201608010547100_AddIsHiddenColumn.cs + + 201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs + diff --git a/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.Designer.cs b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.Designer.cs new file mode 100644 index 00000000..b61580bd --- /dev/null +++ b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.Designer.cs @@ -0,0 +1,29 @@ +// +namespace EmpleoDotNet.Data.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] + public sealed partial class RemoveJobOpportunityLikeTableForLikeAndDislikeColumns : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(RemoveJobOpportunityLikeTableForLikeAndDislikeColumns)); + + string IMigrationMetadata.Id + { + get { return "201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs new file mode 100644 index 00000000..287ba004 --- /dev/null +++ b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.cs @@ -0,0 +1,36 @@ +namespace EmpleoDotNet.Data.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class RemoveJobOpportunityLikeTableForLikeAndDislikeColumns : DbMigration + { + public override void Up() + { + DropForeignKey("dbo.JobOpportunityLikes", "JobOpportunityId", "dbo.JobOpportunities"); + DropIndex("dbo.JobOpportunityLikes", new[] { "JobOpportunityId" }); + AddColumn("dbo.JobOpportunities", "Likes", c => c.Int(nullable: false)); + AddColumn("dbo.JobOpportunities", "DisLikes", c => c.Int(nullable: false)); + DropTable("dbo.JobOpportunityLikes"); + } + + public override void Down() + { + CreateTable( + "dbo.JobOpportunityLikes", + c => new + { + Id = c.Int(nullable: false, identity: true), + Like = c.Boolean(nullable: false), + JobOpportunityId = c.Int(nullable: false), + Created = c.DateTime(nullable: false), + }) + .PrimaryKey(t => t.Id); + + DropColumn("dbo.JobOpportunities", "DisLikes"); + DropColumn("dbo.JobOpportunities", "Likes"); + CreateIndex("dbo.JobOpportunityLikes", "JobOpportunityId"); + AddForeignKey("dbo.JobOpportunityLikes", "JobOpportunityId", "dbo.JobOpportunities", "JobOpportunityId", cascadeDelete: true); + } + } +} diff --git a/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.resx b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.resx new file mode 100644 index 00000000..8dc70005 --- /dev/null +++ b/EmpleoDotNet.Data/Migrations/201609072254503_RemoveJobOpportunityLikeTableForLikeAndDislikeColumns.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAO1dW2/cuBV+L9D/IMxTW2Q9vmyC1LB34Yzjjbd2nGacbN8CWqLHQnSZShrHRtFf1of+pP6FkrryLpKiZsZZI0DgEcmPh4eHh7fDc/73n/8e/fwQR949zPIwTY4nezu7Ew8mfhqEyeJ4sipuf3g9+fmnP/7h6G0QP3ifm3wHOB8qmeTHk7uiWB5Op7l/B2OQ78Shn6V5elvs+Gk8BUE63d/d/et0b28KEcQEYXne0cdVUoQxLH+gn7M08eGyWIHoMg1glNffUcq8RPXegxjmS+DD48nbeBnB9DQt3sNi5xQUYOKdRCFAhMxhdDvxQJKkBSgQmYefcjgvsjRZzJfoA4iuH5cQ5bsFUQ5r8g+77Lot2d3HLZl2BRsof5UXaWwIuHdQs2bKFrdi8KRlHWLeW8Tk4hG3umTg8eTX9OZquUyzYpWghInHVnk4izKcneHyLM3gzinKGCY7NMQLj8v4opUSJEz43wtvtoqKVQaPE7gqMhC98D6sbqLQ/xt8vE6/wuQ4WUURSTgiHaVRH9CnD1m6hFnx+BHe1s05DybelC43ZQu2xYgyVRPPk+Jgf+K9R5WDmwi2ckGwY16gBv0CE5iBAgYfQFHALMEYsOQsVztT13VYRLCpDkkiGlMT7xI8XMBkUdwdT9CfE+8sfIBB86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FZWHk9I0fjzs20Lz0yrcmXA5G1hgduwy0KZ2DopkAc/1giqLHGIwt5KEPSXvxVNl+oUiXe6MRjQBP7UYYDY4YqLvtwwW5TntaOElbYKH73OoSJyqecwTrQ0NLSSAbLVmtjrkTsmUL7dXMaDljZAmw3UWk7ia84xI8YI+zycEdQyWuJAzTEj3Ed3Hs4Gl8PCIIoz7yfqaPpxlWDjy+rXKczDRQeBPWAl0KdOF9o858lt2px2MBQ1WRhLvEtYgAAU4CQrwlvgF+W75jwvHzaX5vLY+vcGBufJ1apYrgrUZBjf0IEv8WGJqv4yVDVN89FV6d8nd9EERGaI7VWvkvLFeEv3mcD0TwKBT2HqVxC4Lwv8GmLx2CK9TxNNoJp97eHRNYyXEQLLr5I5wO41zGlD4ncBF8B/7J7hyED6O4Jm+9FpCBYZiPMaoyuPfiIZDuKHn/4PtFQ/m07RAAA= + + + dbo + + \ No newline at end of file diff --git a/EmpleoDotNet.Repository/Contracts/IJobOpportunityLikeRepository.cs b/EmpleoDotNet.Repository/Contracts/IJobOpportunityLikeRepository.cs deleted file mode 100644 index f1e84538..00000000 --- a/EmpleoDotNet.Repository/Contracts/IJobOpportunityLikeRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; -using EmpleoDotNet.Core.Domain; - -namespace EmpleoDotNet.Repository.Contracts -{ - public interface IJobOpportunityLikeRepository : IBaseRepository - { - List GetLikesByJobOpportunityId(int jobOpportunityId); - } -} \ No newline at end of file diff --git a/EmpleoDotNet.Repository/EmpleoDotNet.Repository.csproj b/EmpleoDotNet.Repository/EmpleoDotNet.Repository.csproj index 14cdae05..d10d40fe 100644 --- a/EmpleoDotNet.Repository/EmpleoDotNet.Repository.csproj +++ b/EmpleoDotNet.Repository/EmpleoDotNet.Repository.csproj @@ -74,8 +74,6 @@ - - diff --git a/EmpleoDotNet.Repository/JobOpportunityLikeRepository.cs b/EmpleoDotNet.Repository/JobOpportunityLikeRepository.cs deleted file mode 100644 index 5ac1fc9f..00000000 --- a/EmpleoDotNet.Repository/JobOpportunityLikeRepository.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using EmpleoDotNet.Core.Domain; -using EmpleoDotNet.Data; -using EmpleoDotNet.Repository.Contracts; - -namespace EmpleoDotNet.Repository -{ - public class JobOpportunityLikeRepository : BaseRepository, IJobOpportunityLikeRepository - { - public JobOpportunityLikeRepository(EmpleadoContext context) : base(context) - { - } - - public List GetLikesByJobOpportunityId(int jobOpportunityId) - { - return DbSet.Where(x => x.JobOpportunityId == jobOpportunityId).ToList(); - } - } -} diff --git a/EmpleoDotNet.Repository/JobOpportunityRepository.cs b/EmpleoDotNet.Repository/JobOpportunityRepository.cs index 73227a1d..2cade7c0 100644 --- a/EmpleoDotNet.Repository/JobOpportunityRepository.cs +++ b/EmpleoDotNet.Repository/JobOpportunityRepository.cs @@ -18,7 +18,6 @@ public List GetAllJobOpportunities() { var jobOpportunities = DbSet .Include(x => x.JobOpportunityLocation) - .Include(x => x.JobOpportunityLikes) .OrderByDescending(x => x.PublishedDate); return jobOpportunities.ToList(); @@ -61,7 +60,6 @@ public JobOpportunity GetJobOpportunityById(int? id) return DbSet.Include(x => x.JobOpportunityLocation) .Include(x => x.JoelTest) - .Include(x => x.JobOpportunityLikes) .FirstOrDefault(x => x.Id.Equals(id.Value)); } @@ -88,11 +86,10 @@ public IPagedList GetAllJobOpportunitiesPagedByFilters(JobOpport parameter.PageSize = 15; var jobs = DbSet - .Include(x => x.JobOpportunityLocation) - .Include(x => x.JobOpportunityLikes); + .Include(x => x.JobOpportunityLocation); jobs = jobs - .OrderByDescending(x => x.JobOpportunityLikes.Count(l => l.Like)) + .OrderByDescending(x => x.Likes) .ThenByDescending(x => x.Id); //Filter by JobCategory @@ -166,9 +163,8 @@ AND jol.longitude public List GetLatestJobOpportunity(int quantity) { return GetAll().OrderByDescending(m => m.PublishedDate) - .ThenByDescending(x => x.JobOpportunityLikes.Count(c => c.Like)) + .ThenByDescending(x => x.Likes) .Include(m => m.JobOpportunityLocation) - .Include(x => x.JobOpportunityLikes) .Take(quantity) .ToList(); } diff --git a/EmpleoDotNet.Repository/UserProfileRepository.cs b/EmpleoDotNet.Repository/UserProfileRepository.cs index 973cc6ab..75e2847a 100644 --- a/EmpleoDotNet.Repository/UserProfileRepository.cs +++ b/EmpleoDotNet.Repository/UserProfileRepository.cs @@ -18,9 +18,7 @@ public UserProfileRepository(EmpleadoContext context) : base(context) public UserProfile GetByUserId(string userId) { - return DbSet.Where(x => x.UserId == userId) - .Include(x => x.JobOpportunities.Select(j => j.JobOpportunityLikes)) - .FirstOrDefault(); + return DbSet.FirstOrDefault(x => x.UserId == userId); } } } diff --git a/EmpleoDotNet.Tests/Services/Twitter/TwitterServiceTests.cs b/EmpleoDotNet.Tests/Services/Twitter/TwitterServiceTests.cs index e5922d8a..d716a9ae 100644 --- a/EmpleoDotNet.Tests/Services/Twitter/TwitterServiceTests.cs +++ b/EmpleoDotNet.Tests/Services/Twitter/TwitterServiceTests.cs @@ -26,7 +26,7 @@ public void SetUp() { _sut = new TwitterService(); _jobOpportunityService = Substitute.For(); - _jobOpportunityController = new JobOpportunityController(_jobOpportunityService, _sut, null); + _jobOpportunityController = new JobOpportunityController(_jobOpportunityService, _sut); } [Test] diff --git a/EmpleoDotNet.Tests/Web/Controllers/JobOpportunityControllerTest.cs b/EmpleoDotNet.Tests/Web/Controllers/JobOpportunityControllerTest.cs index 89b2b8ae..49692fec 100644 --- a/EmpleoDotNet.Tests/Web/Controllers/JobOpportunityControllerTest.cs +++ b/EmpleoDotNet.Tests/Web/Controllers/JobOpportunityControllerTest.cs @@ -37,7 +37,7 @@ public void SetUp() { _jobOpportunityService = Substitute.For(); _twitterService = Substitute.For(); - _sut = new JobOpportunityController(_jobOpportunityService, _twitterService, null); + _sut = new JobOpportunityController(_jobOpportunityService, _twitterService); } #region Index diff --git a/EmpleoDotNet/App_Start/EmpleadoModule.cs b/EmpleoDotNet/App_Start/EmpleadoModule.cs index b89ce1cf..8b7efd7e 100644 --- a/EmpleoDotNet/App_Start/EmpleadoModule.cs +++ b/EmpleoDotNet/App_Start/EmpleadoModule.cs @@ -31,8 +31,6 @@ public override void Load() Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); } } } \ No newline at end of file diff --git a/EmpleoDotNet/Controllers/JobOpportunityController.cs b/EmpleoDotNet/Controllers/JobOpportunityController.cs index d7eb5674..a3807858 100644 --- a/EmpleoDotNet/Controllers/JobOpportunityController.cs +++ b/EmpleoDotNet/Controllers/JobOpportunityController.cs @@ -9,12 +9,9 @@ using EmpleoDotNet.ViewModel.JobOpportunity; using reCAPTCHA.MVC; using System; -using System.Linq; using System.Net; using EmpleoDotNet.Core.Domain; -using EmpleoDotNet.ViewModel.JobOpportunityLike; using Microsoft.AspNet.Identity; -using Tweetinvi.Logic.JsonConverters; namespace EmpleoDotNet.Controllers { @@ -213,29 +210,28 @@ public async Task Wizard(Wizard model) } [HttpPost] - public JsonResult Like(JobOpportunityLike model) + public JsonResult Like(int jobOpportunityId, bool like) { - var cookieName = GetLikeCookieName(model.JobOpportunityId); + var cookieName = GetLikeCookieName(jobOpportunityId); if (CookieHelper.Exists(cookieName)) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { error = true, message = "Ya has votado por este empleo." }); } + + _jobOpportunityService.CreateNewReaction(jobOpportunityId, like); - _jobOpportunityLikeService.CreateNewLike(model); + CookieHelper.Set(cookieName, jobOpportunityId.ToString()); - CookieHelper.Set(cookieName, model.JobOpportunityId.ToString()); - - var jobLikeData = _jobOpportunityLikeService.GetLikesByJobOpportunityId(model.JobOpportunityId); - - var jobOpportunityLikeData = new JobOpportunityLikeViewModel - { - Likes = jobLikeData.Count(x => x.Like), - DisLikes = jobLikeData.Count(x => !x.Like) - }; - - return Json(new { error = false, data = jobOpportunityLikeData }); + var jobOpportunity = _jobOpportunityService.GetJobOpportunityById(jobOpportunityId); + return jobOpportunity == null + ? Json(new { error = true, message = "No se encuentra empleo con el id indicado" }) + : Json(new { error = false, data = new + { + jobOpportunity.Likes, + jobOpportunity.DisLikes + }}); } /// @@ -298,16 +294,13 @@ private bool IsJobOpportunityOwner(string title) public JobOpportunityController( IJobOpportunityService jobOpportunityService, - ITwitterService twitterService, - IJobOpportunityLikeService jobOpportunityLikeService) + ITwitterService twitterService) { _jobOpportunityService = jobOpportunityService; _twitterService = twitterService; - _jobOpportunityLikeService = jobOpportunityLikeService; } private readonly IJobOpportunityService _jobOpportunityService; private readonly ITwitterService _twitterService; - private readonly IJobOpportunityLikeService _jobOpportunityLikeService; } } \ No newline at end of file diff --git a/EmpleoDotNet/EmpleoDotNet.csproj b/EmpleoDotNet/EmpleoDotNet.csproj index c572accb..89970827 100644 --- a/EmpleoDotNet/EmpleoDotNet.csproj +++ b/EmpleoDotNet/EmpleoDotNet.csproj @@ -310,7 +310,6 @@ - diff --git a/EmpleoDotNet/Properties/AssemblyInfo.cs b/EmpleoDotNet/Properties/AssemblyInfo.cs index 280e1ef6..42c81d13 100644 --- a/EmpleoDotNet/Properties/AssemblyInfo.cs +++ b/EmpleoDotNet/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.4.0.0")] -[assembly: AssemblyFileVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.5.0.0")] +[assembly: AssemblyFileVersion("0.5.0.0")] diff --git a/EmpleoDotNet/ViewModel/JobOpportunityLike/JobOpportunityLikeViewModel.cs b/EmpleoDotNet/ViewModel/JobOpportunityLike/JobOpportunityLikeViewModel.cs deleted file mode 100644 index 9e2e726d..00000000 --- a/EmpleoDotNet/ViewModel/JobOpportunityLike/JobOpportunityLikeViewModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace EmpleoDotNet.ViewModel.JobOpportunityLike -{ - public class JobOpportunityLikeViewModel - { - public int Likes { get; set; } - - public int DisLikes { get; set; } - } -} \ No newline at end of file diff --git a/EmpleoDotNet/Views/JobOpportunity/Detail.cshtml b/EmpleoDotNet/Views/JobOpportunity/Detail.cshtml index 427d9901..44b0a728 100644 --- a/EmpleoDotNet/Views/JobOpportunity/Detail.cshtml +++ b/EmpleoDotNet/Views/JobOpportunity/Detail.cshtml @@ -110,12 +110,7 @@ -   - diff --git a/EmpleoDotNet/Views/Shared/_JobListPartial.cshtml b/EmpleoDotNet/Views/Shared/_JobListPartial.cshtml index 72b2dae8..e809f903 100644 --- a/EmpleoDotNet/Views/Shared/_JobListPartial.cshtml +++ b/EmpleoDotNet/Views/Shared/_JobListPartial.cshtml @@ -57,12 +57,7 @@

- @(jobOpportunity.JobOpportunityLikes?.Count(x => x.Like).FormatThousand()) - -   - - - @(jobOpportunity.JobOpportunityLikes?.Count(x => !x.Like).FormatThousand()) + @(jobOpportunity.Likes.FormatThousand())