Browse Source

Emails done

master
Mehrdadmaskull 10 years ago
parent
commit
f041902f71
17 changed files with 533 additions and 127 deletions
  1. +0
    -3
      Sevomin.Models/Avalin.cs
  2. +1
    -5
      Sevomin.Models/AvalinViewModel.cs
  3. +4
    -0
      Sevomin.Models/Dovomin.cs
  4. +16
    -12
      Sevomin.Models/DovominViewModel.cs
  5. +3
    -3
      Sevomin.Models/Helpers/ScheduledTasks/ExpiringJob.cs
  6. +6
    -10
      Sevomin.Models/Helpers/ScheduledTasks/NewApplication.cs
  7. +4
    -7
      Sevomin.Models/Helpers/ScheduledTasks/NewJob.cs
  8. +28
    -35
      Sevomin.Models/Helpers/SevominEmailer.cs
  9. +29
    -0
      Sevomin.Models/Migrations/201503091139500_Init.Designer.cs
  10. +268
    -0
      Sevomin.Models/Migrations/201503091139500_Init.cs
  11. +126
    -0
      Sevomin.Models/Migrations/201503091139500_Init.resx
  12. +5
    -5
      Sevomin.Models/Sevomin.Models.csproj
  13. +10
    -10
      Sevomin.WebFrontend.Controllers/AccountController.cs
  14. +19
    -22
      Sevomin.WebFrontend.Controllers/JobController.cs
  15. +5
    -5
      Sevomin.WebFrontend/Content/common.css
  16. +3
    -9
      Sevomin.WebFrontend/Views/Account/ProfileAvalin.cshtml
  17. +6
    -1
      Sevomin.WebFrontend/Views/Account/ProfileDovomin.cshtml

+ 0
- 3
Sevomin.Models/Avalin.cs View File

@ -24,9 +24,6 @@ namespace Sevomin.Models
[EmailValidation(ErrorMessage="ای میل معتبر نیست")] [EmailValidation(ErrorMessage="ای میل معتبر نیست")]
public string EMail { get; set; } public string EMail { get; set; }
[DefaultValue(false)]
public bool OptOutEmail { get; set; }
public virtual ICollection<Job> Jobs { get; set; } public virtual ICollection<Job> Jobs { get; set; }
public Avalin() public Avalin()


+ 1
- 5
Sevomin.Models/AvalinViewModel.cs View File

@ -40,11 +40,7 @@ namespace Sevomin.Models
[RegularExpression(@"^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z])\.)+[a-zA-Z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$", ErrorMessage = "لطفا ایمیل معتبر وارد کنید.")] [RegularExpression(@"^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z])\.)+[a-zA-Z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$", ErrorMessage = "لطفا ایمیل معتبر وارد کنید.")]
[DisplayName("ایمیل")] [DisplayName("ایمیل")]
public string EMail { get; set; } public string EMail { get; set; }
[DefaultValue(false)]
[DisplayName("دریافت ایمیل")]
public bool OptOutEmail { get; set; }
public AvalinViewModel(Avalin avalin) public AvalinViewModel(Avalin avalin)
{ {
CompanyName = avalin.CompanyName; CompanyName = avalin.CompanyName;


+ 4
- 0
Sevomin.Models/Dovomin.cs View File

@ -1,6 +1,7 @@
 
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Sevomin.Models namespace Sevomin.Models
{ {
@ -17,6 +18,9 @@ namespace Sevomin.Models
public string EnglishResume { get; set; } public string EnglishResume { get; set; }
public string PersianResume { get; set; } public string PersianResume { get; set; }
[DefaultValue(false)]
public bool OptOutEmail { get; set; }
public virtual ICollection<DovominParameter> DovominParameters { get; set; } public virtual ICollection<DovominParameter> DovominParameters { get; set; }
public virtual ICollection<DovominJob> DovominJobs { get; set; } public virtual ICollection<DovominJob> DovominJobs { get; set; }


+ 16
- 12
Sevomin.Models/DovominViewModel.cs View File

@ -19,7 +19,7 @@ namespace Sevomin.Models
{ {
get get
{ {
return string.Format("{0} {1}", this.FirstName, this.LastName);
return string.Format("{0} {1}", FirstName, LastName);
} }
} }
@ -39,8 +39,8 @@ namespace Sevomin.Models
{ {
get get
{ {
if (this.BirthDate.HasValue)
return DateAssist.ToShamsi(this.BirthDate.Value);
if (BirthDate.HasValue)
return DateAssist.ToShamsi(BirthDate.Value);
else else
return string.Empty; return string.Empty;
} }
@ -65,19 +65,23 @@ namespace Sevomin.Models
[DisplayName("پاره وقت")] [DisplayName("پاره وقت")]
public bool IsPartTime { get; set; } public bool IsPartTime { get; set; }
[DefaultValue(false)]
[DisplayName("دریافت ایمیل")]
public bool OptOutEmail { get; set; }
public IList<DovominParameterViewModel> Parameters; public IList<DovominParameterViewModel> Parameters;
public DovominViewModel(Dovomin dovomin) public DovominViewModel(Dovomin dovomin)
{ {
this.Id = dovomin.Id;
this.FirstName = dovomin.FirstName;
this.LastName = dovomin.LastName;
this.IsFullTime = dovomin.IsFulltime;
this.IsPartTime = dovomin.IsPartTime;
this.BirthDate = dovomin.BirthDate;
this.Description = dovomin.Description;
this.EnglishResume = dovomin.EnglishResume;
this.PersianResume = dovomin.PersianResume;
Id = dovomin.Id;
FirstName = dovomin.FirstName;
LastName = dovomin.LastName;
IsFullTime = dovomin.IsFulltime;
IsPartTime = dovomin.IsPartTime;
BirthDate = dovomin.BirthDate;
Description = dovomin.Description;
EnglishResume = dovomin.EnglishResume;
PersianResume = dovomin.PersianResume;
ParameterRepository.Current.AddParametersToDovomin(dovomin); ParameterRepository.Current.AddParametersToDovomin(dovomin);


+ 3
- 3
Sevomin.Models/Helpers/ScheduledTasks/ExpiringJob.cs View File

@ -15,10 +15,10 @@ namespace Sevomin.Models.Helpers.ScheduledTasks
var expiringJobs = JobRepository.Current.ListAll().ToList().Where(j => j.ExpireDate.Date == DateTime.UtcNow.AddDays(-2).Date); var expiringJobs = JobRepository.Current.ListAll().ToList().Where(j => j.ExpireDate.Date == DateTime.UtcNow.AddDays(-2).Date);
foreach (var job in expiringJobs) foreach (var job in expiringJobs)
{ {
SevominEmailer emailer = new SevominEmailer();
emailer.EmailType = EmailType.ExpiringJob;
SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.ExpiringJob};
emailer.Parameters.Add("", ""); emailer.Parameters.Add("", "");
await emailer.SendAsync(string.IsNullOrWhiteSpace(job.ContactPersonEMail) ? job.Avalin.Email : job.ContactPersonEMail, true);
await emailer.SendAsync(string.IsNullOrWhiteSpace(job.ContactPersonEMail) ? job.Avalin.Email : job.ContactPersonEMail, true, false);
} }
} }
} }

+ 6
- 10
Sevomin.Models/Helpers/ScheduledTasks/NewApplication.cs View File

@ -1,9 +1,6 @@
using FluentScheduler;
using System;
using System.Collections.Generic;
using System;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentScheduler;
namespace Sevomin.Models.Helpers.ScheduledTasks namespace Sevomin.Models.Helpers.ScheduledTasks
{ {
@ -19,18 +16,17 @@ namespace Sevomin.Models.Helpers.ScheduledTasks
foreach (var apply in applies) foreach (var apply in applies)
{ {
SevominEmailer emailer = new SevominEmailer();
emailer.EmailType = EmailType.NewApplication;
SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.NewApplication};
emailer.Parameters.Add("avalin-name", avalin.DisplayName); emailer.Parameters.Add("avalin-name", avalin.DisplayName);
emailer.Parameters.Add("avalin-contact", string.IsNullOrWhiteSpace(apply.Job.ContactPersonName) ? "" : apply.Job.ContactPersonName); emailer.Parameters.Add("avalin-contact", string.IsNullOrWhiteSpace(apply.Job.ContactPersonName) ? "" : apply.Job.ContactPersonName);
emailer.Parameters.Add("dovomin-name", apply.Dovomin.DisplayName); emailer.Parameters.Add("dovomin-name", apply.Dovomin.DisplayName);
if (string.IsNullOrWhiteSpace(apply.Job.ContactPersonEMail)) if (string.IsNullOrWhiteSpace(apply.Job.ContactPersonEMail))
await emailer.SendAsync(avalin.Email, true);
await emailer.SendAsync(avalin.Email, true, false);
else else
{ {
await emailer.SendAsync(avalin.Email, true);
await emailer.SendAsync(apply.Job.ContactPersonEMail, true);
await emailer.SendAsync(avalin.Email, true, false);
await emailer.SendAsync(apply.Job.ContactPersonEMail, true, false);
} }
} }
} }


+ 4
- 7
Sevomin.Models/Helpers/ScheduledTasks/NewJob.cs View File

@ -1,10 +1,7 @@
using FluentScheduler;
using Sevomin.Models.Repositories;
using System;
using System.Collections.Generic;
using System;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentScheduler;
using Sevomin.Models.Repositories;
namespace Sevomin.Models.Helpers.ScheduledTasks namespace Sevomin.Models.Helpers.ScheduledTasks
{ {
@ -21,7 +18,7 @@ namespace Sevomin.Models.Helpers.ScheduledTasks
emailer.EmailType = EmailType.NewJob; emailer.EmailType = EmailType.NewJob;
emailer.Parameters.Add("display-name", dovomin.DisplayName); emailer.Parameters.Add("display-name", dovomin.DisplayName);
await emailer.SendAsync(dovomin.Email, true);
await emailer.SendAsync(dovomin.Email, true, ((Dovomin) dovomin).OptOutEmail);
} }
} }
} }


+ 28
- 35
Sevomin.Models/Helpers/SevominEmailer.cs View File

@ -60,7 +60,7 @@ namespace Sevomin.Models.Helpers
EmailType = emailType; EmailType = emailType;
} }
public async Task SendAsync(string to, bool isHtml)
public async Task SendAsync(string to, bool isHtml, bool optedOut)
{ {
SmtpClient client = new SmtpClient(); SmtpClient client = new SmtpClient();
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
@ -71,7 +71,7 @@ namespace Sevomin.Models.Helpers
case EmailType.EmailConfirmation: case EmailType.EmailConfirmation:
template = template =
File.ReadAllText(EmailConfirmationFilePath, Encoding.UTF8); File.ReadAllText(EmailConfirmationFilePath, Encoding.UTF8);
msg.Subject = "تایید عضویت در سومین";
msg.Subject = "تایید عضویت";
break; break;
case EmailType.PasswordReset: case EmailType.PasswordReset:
template = template =
@ -86,12 +86,12 @@ namespace Sevomin.Models.Helpers
case EmailType.NewApplication: case EmailType.NewApplication:
template = template =
File.ReadAllText(NewApplicationFilePath, Encoding.UTF8); File.ReadAllText(NewApplicationFilePath, Encoding.UTF8);
msg.Subject = "اعلام آمادگی جدید برای فرصت شغلی اعلام شده در سومین";
msg.Subject = "اعلام آمادگی جدید برای فرصت شغلی اعلام شده";
break; break;
case EmailType.NewJob: case EmailType.NewJob:
template = template =
File.ReadAllText(NewJobFilePath, Encoding.UTF8); File.ReadAllText(NewJobFilePath, Encoding.UTF8);
msg.Subject = "آگهی استخدام جدید در سومین";
msg.Subject = "آگهی استخدام جدید";
break; break;
default: default:
template = string.Empty; template = string.Empty;
@ -99,44 +99,37 @@ namespace Sevomin.Models.Helpers
break; break;
} }
//Working
//msg.To.Add("[email protected]");
//msg.Bcc.Add("[email protected]");
//string subj = subject;
//string subj2 = "asdasd";
if (!optedOut)
{
foreach (var address in to.Split(','))
msg.To.Add(address);
//msg.Bcc.Add("[email protected]");
Func<string> getBody = () =>
{
foreach (var param in Parameters)
template = template.Replace(string.Format("[{0}]", param.Key), param.Value);
//Not Working
return template;
};
foreach (var address in to.Split(','))
msg.To.Add(address);
//msg.Bcc.Add("[email protected]");
Func<string> getBody = () =>
{
foreach (var param in Parameters)
template = template.Replace(string.Format("[{0}]", param.Key), param.Value);
msg.Body = getBody();
return template;
};
msg.Body = getBody();
msg.From = new MailAddress("[email protected]");
msg.From = new MailAddress("[email protected]");
msg.SubjectEncoding = Encoding.UTF8;
msg.BodyEncoding = Encoding.UTF8;
msg.SubjectEncoding = Encoding.UTF8;
msg.BodyEncoding = Encoding.UTF8;
msg.IsBodyHtml = isHtml;
msg.IsBodyHtml = isHtml;
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "4XdWMRVFBO-pow4I1md1Bw");
client.EnableSsl = true;
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("[email protected]", "4XdWMRVFBO-pow4I1md1Bw");
client.EnableSsl = true;
await Task.Run(() =>
{
client.Send(msg);
});
await Task.Run(() =>
{
client.Send(msg);
});
}
} }
} }
} }

+ 29
- 0
Sevomin.Models/Migrations/201503091139500_Init.Designer.cs View File

@ -0,0 +1,29 @@
// <auto-generated />
namespace Sevomin.Models.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.1.0-30225")]
public sealed partial class Init : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(Init));
string IMigrationMetadata.Id
{
get { return "201503091139500_Init"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}

+ 268
- 0
Sevomin.Models/Migrations/201503091139500_Init.cs View File

@ -0,0 +1,268 @@
namespace Sevomin.Models.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class Init : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.DovominJobs",
c => new
{
Id = c.Long(nullable: false, identity: true),
DovominId = c.String(nullable: false, maxLength: 128),
JobId = c.Long(nullable: false),
ApplyDate = c.DateTime(nullable: false),
CoverLetter = c.String(),
Affinity = c.Decimal(nullable: false, precision: 18, scale: 2),
MinimumRequirement = c.Boolean(nullable: false),
AvalinSeen = c.DateTime(),
AvalinComment = c.String(),
AvalinDelete = c.Boolean(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Dovomin", t => t.DovominId)
.ForeignKey("dbo.Jobs", t => t.JobId, cascadeDelete: true)
.Index(t => new { t.DovominId, t.JobId }, unique: true, name: "IX_DovominJobUniqueIndex")
.Index(t => t.JobId);
CreateTable(
"dbo.AspNetUsers",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
DisplayName = c.String(),
SignUpDate = c.DateTime(nullable: false),
ConfirmationCode = c.String(),
Email = c.String(maxLength: 256),
EmailConfirmed = c.Boolean(nullable: false),
PasswordHash = c.String(),
SecurityStamp = c.String(),
PhoneNumber = c.String(),
PhoneNumberConfirmed = c.Boolean(nullable: false),
TwoFactorEnabled = c.Boolean(nullable: false),
LockoutEndDateUtc = c.DateTime(),
LockoutEnabled = c.Boolean(nullable: false),
AccessFailedCount = c.Int(nullable: false),
UserName = c.String(nullable: false, maxLength: 256),
})
.PrimaryKey(t => t.Id)
.Index(t => t.UserName, unique: true, name: "UserNameIndex");
CreateTable(
"dbo.AspNetUserClaims",
c => new
{
Id = c.Int(nullable: false, identity: true),
UserId = c.String(nullable: false, maxLength: 128),
ClaimType = c.String(),
ClaimValue = c.String(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
.Index(t => t.UserId);
CreateTable(
"dbo.DovominParameters",
c => new
{
Id = c.Long(nullable: false, identity: true),
ParameterId = c.Long(nullable: false),
DovominId = c.String(nullable: false, maxLength: 128),
StringValue = c.String(),
NumericValue = c.Decimal(precision: 18, scale: 2),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Dovomin", t => t.DovominId)
.ForeignKey("dbo.Parameters", t => t.ParameterId, cascadeDelete: true)
.Index(t => new { t.ParameterId, t.DovominId }, unique: true, name: "IX_DovominParameterUniqueIndex")
.Index(t => t.DovominId);
CreateTable(
"dbo.Parameters",
c => new
{
Id = c.Long(nullable: false, identity: true),
Name = c.String(nullable: false),
Moscow = c.Boolean(nullable: false),
DisplayMethod = c.Byte(nullable: false),
DisplayFormat = c.String(maxLength: 50),
GroupName = c.String(nullable: false),
CommentAvalin = c.String(maxLength: 140),
CommentDovomin = c.String(maxLength: 140),
ParameterValueId = c.String(maxLength: 50),
BasePoint = c.Int(nullable: false),
ParameterType = c.Int(nullable: false),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.JobParameters",
c => new
{
Id = c.Long(nullable: false, identity: true),
ParameterId = c.Long(nullable: false),
JobId = c.Long(nullable: false),
StringValue = c.String(),
NumericValue = c.Decimal(precision: 18, scale: 2),
Moscow = c.Byte(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Jobs", t => t.JobId, cascadeDelete: true)
.ForeignKey("dbo.Parameters", t => t.ParameterId, cascadeDelete: true)
.Index(t => new { t.ParameterId, t.JobId }, unique: true, name: "IX_JobParameterUniqueIndex")
.Index(t => t.JobId);
CreateTable(
"dbo.Jobs",
c => new
{
Id = c.Long(nullable: false, identity: true),
AvalinId = c.String(nullable: false, maxLength: 128),
CreateDate = c.DateTime(nullable: false),
ExpireDate = c.DateTime(nullable: false),
Description = c.String(),
ResumeType = c.Byte(nullable: false),
ContactPersonName = c.String(),
ContactPersonPhone = c.String(),
ContactPersonEMail = c.String(),
ShowCompanyName = c.Boolean(nullable: false),
ShowCompanyLogo = c.Boolean(nullable: false),
IsFullTime = c.Boolean(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Avalin", t => t.AvalinId)
.Index(t => t.AvalinId);
CreateTable(
"dbo.AspNetUserLogins",
c => new
{
LoginProvider = c.String(nullable: false, maxLength: 128),
ProviderKey = c.String(nullable: false, maxLength: 128),
UserId = c.String(nullable: false, maxLength: 128),
})
.PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId })
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
.Index(t => t.UserId);
CreateTable(
"dbo.AspNetUserRoles",
c => new
{
UserId = c.String(nullable: false, maxLength: 128),
RoleId = c.String(nullable: false, maxLength: 128),
})
.PrimaryKey(t => new { t.UserId, t.RoleId })
.ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true)
.ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true)
.Index(t => t.UserId)
.Index(t => t.RoleId);
CreateTable(
"dbo.ParameterValues",
c => new
{
GroupKey = c.String(nullable: false, maxLength: 50),
Value = c.String(nullable: false, maxLength: 50),
NumbericValue = c.Decimal(nullable: false, precision: 18, scale: 2),
})
.PrimaryKey(t => new { t.GroupKey, t.Value })
.Index(t => t.GroupKey);
CreateTable(
"dbo.AspNetRoles",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
Name = c.String(nullable: false, maxLength: 256),
})
.PrimaryKey(t => t.Id)
.Index(t => t.Name, unique: true, name: "RoleNameIndex");
CreateTable(
"dbo.Dovomin",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
FirstName = c.String(),
LastName = c.String(),
BirthDate = c.DateTime(),
IsFulltime = c.Boolean(nullable: false),
IsPartTime = c.Boolean(nullable: false),
Description = c.String(),
EnglishResume = c.String(),
PersianResume = c.String(),
OptOutEmail = c.Boolean(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.AspNetUsers", t => t.Id)
.Index(t => t.Id);
CreateTable(
"dbo.Avalin",
c => new
{
Id = c.String(nullable: false, maxLength: 128),
CompanyName = c.String(nullable: false),
NationalId = c.String(maxLength: 12),
RegisterId = c.String(maxLength: 10),
Address = c.String(),
CompanyPhoneNumber = c.String(),
EMail = c.String(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.AspNetUsers", t => t.Id)
.Index(t => t.Id);
}
public override void Down()
{
DropForeignKey("dbo.Avalin", "Id", "dbo.AspNetUsers");
DropForeignKey("dbo.Dovomin", "Id", "dbo.AspNetUsers");
DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers");
DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers");
DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers");
DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
DropForeignKey("dbo.JobParameters", "ParameterId", "dbo.Parameters");
DropForeignKey("dbo.JobParameters", "JobId", "dbo.Jobs");
DropForeignKey("dbo.Jobs", "AvalinId", "dbo.Avalin");
DropForeignKey("dbo.DovominJobs", "JobId", "dbo.Jobs");
DropForeignKey("dbo.DovominParameters", "ParameterId", "dbo.Parameters");
DropForeignKey("dbo.DovominParameters", "DovominId", "dbo.Dovomin");
DropForeignKey("dbo.DovominJobs", "DovominId", "dbo.Dovomin");
DropIndex("dbo.Avalin", new[] { "Id" });
DropIndex("dbo.Dovomin", new[] { "Id" });
DropIndex("dbo.AspNetRoles", "RoleNameIndex");
DropIndex("dbo.ParameterValues", new[] { "GroupKey" });
DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
DropIndex("dbo.Jobs", new[] { "AvalinId" });
DropIndex("dbo.JobParameters", new[] { "JobId" });
DropIndex("dbo.JobParameters", "IX_JobParameterUniqueIndex");
DropIndex("dbo.DovominParameters", new[] { "DovominId" });
DropIndex("dbo.DovominParameters", "IX_DovominParameterUniqueIndex");
DropIndex("dbo.AspNetUserClaims", new[] { "UserId" });
DropIndex("dbo.AspNetUsers", "UserNameIndex");
DropIndex("dbo.DovominJobs", new[] { "JobId" });
DropIndex("dbo.DovominJobs", "IX_DovominJobUniqueIndex");
DropTable("dbo.Avalin");
DropTable("dbo.Dovomin");
DropTable("dbo.AspNetRoles");
DropTable("dbo.ParameterValues");
DropTable("dbo.AspNetUserRoles");
DropTable("dbo.AspNetUserLogins");
DropTable("dbo.Jobs");
DropTable("dbo.JobParameters");
DropTable("dbo.Parameters");
DropTable("dbo.DovominParameters");
DropTable("dbo.AspNetUserClaims");
DropTable("dbo.AspNetUsers");
DropTable("dbo.DovominJobs");
}
}
}

+ 126
- 0
Sevomin.Models/Migrations/201503091139500_Init.resx
File diff suppressed because it is too large
View File


+ 5
- 5
Sevomin.Models/Sevomin.Models.csproj View File

@ -91,9 +91,9 @@
<Compile Include="Helpers\ScheduledTasks\NewJob.cs" /> <Compile Include="Helpers\ScheduledTasks\NewJob.cs" />
<Compile Include="Helpers\ScheduledTasks\NewApplication.cs" /> <Compile Include="Helpers\ScheduledTasks\NewApplication.cs" />
<Compile Include="JobMiniExternalViewModel.cs" /> <Compile Include="JobMiniExternalViewModel.cs" />
<Compile Include="Migrations\201503030741121_Init.cs" />
<Compile Include="Migrations\201503030741121_Init.Designer.cs">
<DependentUpon>201503030741121_Init.cs</DependentUpon>
<Compile Include="Migrations\201503091139500_Init.cs" />
<Compile Include="Migrations\201503091139500_Init.Designer.cs">
<DependentUpon>201503091139500_Init.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Migrations\Configuration.cs" /> <Compile Include="Migrations\Configuration.cs" />
<Compile Include="ResetPasswordViewModel.cs" /> <Compile Include="ResetPasswordViewModel.cs" />
@ -137,8 +137,8 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Migrations\201503030741121_Init.resx">
<DependentUpon>201503030741121_Init.cs</DependentUpon>
<EmbeddedResource Include="Migrations\201503091139500_Init.resx">
<DependentUpon>201503091139500_Init.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />


+ 10
- 10
Sevomin.WebFrontend.Controllers/AccountController.cs View File

@ -76,7 +76,7 @@ namespace Sevomin.WebFrontend.Controllers
emailer.EmailType = EmailType.EmailConfirmation; emailer.EmailType = EmailType.EmailConfirmation;
emailer.Parameters.Add("display-name", user.DisplayName); emailer.Parameters.Add("display-name", user.DisplayName);
emailer.Parameters.Add("confirmation-code", user.ConfirmationCode); emailer.Parameters.Add("confirmation-code", user.ConfirmationCode);
await emailer.SendAsync(user.Email, true);
await emailer.SendAsync(user.Email, true, false);
#endif #endif
await SignInAsync(user, isPersistent: false); await SignInAsync(user, isPersistent: false);
@ -179,12 +179,13 @@ namespace Sevomin.WebFrontend.Controllers
user.ConfirmationCode = Sevomin.Models.User.GetConfirmationCode(); user.ConfirmationCode = Sevomin.Models.User.GetConfirmationCode();
UserRepository.Current.Save(); UserRepository.Current.Save();
#if !DEBUG #if !DEBUG
SevominEmailer emailer = new SevominEmailer();
emailer.EmailType = EmailType.PasswordReset;
SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.PasswordReset};
emailer.Parameters.Add("display-name", user.DisplayName); emailer.Parameters.Add("display-name", user.DisplayName);
emailer.Parameters.Add("reset-code", user.ConfirmationCode); emailer.Parameters.Add("reset-code", user.ConfirmationCode);
await emailer.SendAsync(user.Email, true);
await emailer.SendAsync(user.Email, true, false);
#endif #endif
ViewBag.Result = new PostResultViewModel(true, "آدرس بازنشانی رمز عبور برای شما ارسال شد."); ViewBag.Result = new PostResultViewModel(true, "آدرس بازنشانی رمز عبور برای شما ارسال شد.");
@ -258,14 +259,13 @@ namespace Sevomin.WebFrontend.Controllers
User u = await UserManager.FindByNameAsync(User.Identity.Name); User u = await UserManager.FindByNameAsync(User.Identity.Name);
if (u is Avalin) if (u is Avalin)
{ {
Avalin avvalin = u as Avalin;
ViewBag.OptOutEmail = avvalin.OptOutEmail;
return View("ProfileAvalin", new AvalinViewModel(avvalin));
return View("ProfileAvalin", new AvalinViewModel((Avalin)u));
} }
else else
{ {
Dovomin dovomin = (Dovomin)u; Dovomin dovomin = (Dovomin)u;
DovominViewModel dvm = new DovominViewModel(dovomin); DovominViewModel dvm = new DovominViewModel(dovomin);
ViewBag.OptOutEmail = dovomin.OptOutEmail;
return View("ProfileDovomin", dvm); return View("ProfileDovomin", dvm);
} }
} }
@ -274,7 +274,7 @@ namespace Sevomin.WebFrontend.Controllers
[HttpPost] [HttpPost]
public async Task<ActionResult> ProfileDovomin(string JalaliBirthDate, string FirstName, public async Task<ActionResult> ProfileDovomin(string JalaliBirthDate, string FirstName,
string LastName, string ContactPersonEMail, bool IsFullTime, string LastName, string ContactPersonEMail, bool IsFullTime,
bool IsPartTime, string Description, HttpPostedFileBase EnglishResume, HttpPostedFileBase PersianResume, FormCollection form)
bool IsPartTime, string Description, bool OptOutEmail, HttpPostedFileBase EnglishResume, HttpPostedFileBase PersianResume, FormCollection form)
{ {
User u = await UserManager.FindByNameAsync(User.Identity.Name); User u = await UserManager.FindByNameAsync(User.Identity.Name);
if (u == null || !(u is Dovomin)) if (u == null || !(u is Dovomin))
@ -289,6 +289,7 @@ namespace Sevomin.WebFrontend.Controllers
dovomin.LastName = LastName; dovomin.LastName = LastName;
dovomin.IsFulltime = IsFullTime; dovomin.IsFulltime = IsFullTime;
dovomin.IsPartTime = IsPartTime; dovomin.IsPartTime = IsPartTime;
dovomin.OptOutEmail = OptOutEmail;
ParameterRepository.Current.AddParametersToDovomin(dovomin); ParameterRepository.Current.AddParametersToDovomin(dovomin);
foreach (var jp in dovomin.DovominParameters) foreach (var jp in dovomin.DovominParameters)
@ -321,7 +322,7 @@ namespace Sevomin.WebFrontend.Controllers
[Authorize(Roles = "Avalin")] [Authorize(Roles = "Avalin")]
[HttpPost] [HttpPost]
public async Task<ActionResult> ProfileAvalin(string CompanyName, string NationalId, string RegisterId, public async Task<ActionResult> ProfileAvalin(string CompanyName, string NationalId, string RegisterId,
string Address, string CompanyPhoneNumber, string EMail, bool OptOutEmail)
string Address, string CompanyPhoneNumber, string EMail)
{ {
User u = await UserManager.FindByNameAsync(User.Identity.Name); User u = await UserManager.FindByNameAsync(User.Identity.Name);
try try
@ -335,7 +336,6 @@ namespace Sevomin.WebFrontend.Controllers
avalin.Address = Address; avalin.Address = Address;
avalin.CompanyPhoneNumber = CompanyPhoneNumber; avalin.CompanyPhoneNumber = CompanyPhoneNumber;
avalin.Email = EMail; avalin.Email = EMail;
avalin.OptOutEmail = OptOutEmail;
SevominDbContext.Current.SaveChanges(); SevominDbContext.Current.SaveChanges();


+ 19
- 22
Sevomin.WebFrontend.Controllers/JobController.cs View File

@ -93,28 +93,25 @@ namespace Sevomin.WebFrontend.Controllers
Description, ShowCompanyLogo, ResumeType, form, job); Description, ShowCompanyLogo, ResumeType, form, job);
JobRepository.Current.Save(); JobRepository.Current.Save();
if (!u.OptOutEmail)
try
{ {
try
{
foreach (var dovomin in UserRepository.Current.ListAll().Where(user => user is Dovomin && user.EmailConfirmed))
{
SevominEmailer emailer = new SevominEmailer();
emailer.EmailType = EmailType.NewJob;
emailer.Parameters.Add("display-name", dovomin.DisplayName);
await emailer.SendAsync(dovomin.Email, true);
}
}
catch (Exception e)
{
var elmah = new Elmah.Error(e);
Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(elmah);
}
foreach (
var dovomin in UserRepository.Current.ListAll().Where(user => user is Dovomin && user.EmailConfirmed))
{
SevominEmailer emailer = new SevominEmailer {EmailType = EmailType.NewJob};
emailer.Parameters.Add("display-name", dovomin.DisplayName);
await emailer.SendAsync(dovomin.Email, true, ((Dovomin)dovomin).OptOutEmail);
}
} }
ViewBag.Result = new PostResultViewModel(true, "آگهی شما با موفقیت منتشر شد.");
catch (Exception e)
{
var elmah = new Elmah.Error(e);
Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(elmah);
}
ViewBag.Result = new PostResultViewModel(true, "آگهی شما با موفقیت منتشر شد.");
return RedirectToAction("SingleJob", new { jobId = job.Id }); return RedirectToAction("SingleJob", new { jobId = job.Id });
} }
@ -275,11 +272,11 @@ namespace Sevomin.WebFrontend.Controllers
emailer.Parameters.Add("avalin-contact", string.IsNullOrWhiteSpace(dj.Job.ContactPersonName) ? "" : dj.Job.ContactPersonName); emailer.Parameters.Add("avalin-contact", string.IsNullOrWhiteSpace(dj.Job.ContactPersonName) ? "" : dj.Job.ContactPersonName);
emailer.Parameters.Add("dovomin-name", dj.Dovomin.DisplayName); emailer.Parameters.Add("dovomin-name", dj.Dovomin.DisplayName);
await emailer.SendAsync(job.Avalin.Email, true);
await emailer.SendAsync(job.Avalin.Email, true, true);
if (!string.IsNullOrWhiteSpace(dj.Job.ContactPersonEMail)) if (!string.IsNullOrWhiteSpace(dj.Job.ContactPersonEMail))
{ {
await emailer.SendAsync(dj.Job.ContactPersonEMail, true);
await emailer.SendAsync(dj.Job.ContactPersonEMail, true, user.OptOutEmail);
} }
} }
catch (Exception e) catch (Exception e)


+ 5
- 5
Sevomin.WebFrontend/Content/common.css View File

@ -5,11 +5,11 @@
url('/fonts/BKoodakBold.ttf') format('truetype'); /* Saf3—5, Chrome4+, FF3.5, Opera 10+ */ url('/fonts/BKoodakBold.ttf') format('truetype'); /* Saf3—5, Chrome4+, FF3.5, Opera 10+ */
} }
@font-face {
font-family: "nasim";
src: url(/fonts/sevomin-nasim.woff) format("woff");
font-weight: normal;
font-style: normal;
@font-face {
font-family: "nasim";
src: url(/fonts/sevomin-nasim.woff) format("woff");
font-weight: normal;
font-style: normal;
} }
@font-face { @font-face {


+ 3
- 9
Sevomin.WebFrontend/Views/Account/ProfileAvalin.cshtml View File

@ -1,10 +1,10 @@
@using System.Collections.Concurrent
@model Sevomin.Models.AvalinViewModel
@using Sevomin.Models
@model AvalinViewModel
@{ @{
ViewBag.Title = "ویرایش پروفایل"; ViewBag.Title = "ویرایش پروفایل";
} }
@Html.Partial("PostResult", ViewBag.Result as Sevomin.Models.PostResultViewModel)
@Html.Partial("PostResult", ViewBag.Result as PostResultViewModel)
<div class="page-header rtl"> <div class="page-header rtl">
<h1>ویرایش پروفایل <small>@Model.DisplayName</small></h1> <h1>ویرایش پروفایل <small>@Model.DisplayName</small></h1>
@ -55,12 +55,6 @@
@Html.TextBoxFor(model => model.RegisterId, new {@class = "form-control"}) @Html.TextBoxFor(model => model.RegisterId, new {@class = "form-control"})
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-6">
@Html.LabelFor(model => model.OptOutEmail, new { @class = "col-md-3 col-md-push-9" })
@Html.CheckBox("OptOutEmail", (bool)ViewBag.OptOutEmail, new {@class = "col-md-2 col-md-push-5" })
</div>
</div>
</div> </div>
</div> </div>
</div> </div>


+ 6
- 1
Sevomin.WebFrontend/Views/Account/ProfileDovomin.cshtml View File

@ -90,6 +90,12 @@
@Html.DisplayNameFor(model => model.IsPartTime) @Html.CheckBoxFor(model => model.IsPartTime) @Html.DisplayNameFor(model => model.IsPartTime) @Html.CheckBoxFor(model => model.IsPartTime)
</label> </label>
</div> </div>
<div class="row">
<div class="col-md-6">
@Html.LabelFor(model => model.OptOutEmail, new { @class = "col-md-3 col-md-push-9" })
@Html.CheckBox("OptOutEmail", (bool)ViewBag.OptOutEmail, new { @class = "col-md-2 col-md-push-5 checkbox" })
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -109,7 +115,6 @@
} }
</div> </div>
</div> </div>
} }
</div> </div>
</div> </div>


Loading…
Cancel
Save