-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddjoboffer.aspx.cs
More file actions
78 lines (48 loc) · 2.31 KB
/
addjoboffer.aspx.cs
File metadata and controls
78 lines (48 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class addjoboffer : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void Page_Init(object sender, EventArgs e) {
Logger log;
if (Session["LoggerID"] == null || (log = Logger.GetLogger(Session["LoggerID"])) == null || !log.IsCompany) {
Response.Redirect("default.aspx");
} else {
if (!IsPostBack) {
lstRegion.Items.Add(new ListItem("-- Select a region --", "-1"));
foreach (Region reg in Region.GetRegions()) {
lstRegion.Items.Add(new ListItem(reg.Name, reg.ID.ToString()));
}
lstRegion.SelectedValue = "-1";
lstContact.Items.Add(new ListItem("-- Select a contact --", "-1"));
foreach (User usr in global::User.GetAll().OrderBy(u => u.Lastname).ThenBy(u => u.Firstname)) {
lstContact.Items.Add(new ListItem(string.Format("{0}, {1}", usr.Lastname, usr.Firstname), usr.ID.ToString()));
}
lstContact.SelectedValue = "-1";
}
}
}
#region - Interaction -
protected void custTitle_ServerValidate(object source, ServerValidateEventArgs args) {
Logger log;
if (this.IsValid && Session["LoggerID"] != null && (log = Logger.GetLogger(Session["LoggerID"])) != null && log.IsCompany) {
args.IsValid = !log.Company.HasOffer(txtTitle.Text.Trim());
}
}
protected void lnkSubmit_Click(object sender, EventArgs e) {
Logger log;
if (this.IsValid && Session["LoggerID"] != null && (log = Logger.GetLogger(Session["LoggerID"])) != null && log.IsCompany) {
int? region = null;
int? contact = null;
if (lstRegion.SelectedValue != "-1") region = Convert.ToInt32(lstRegion.SelectedValue);
if (lstContact.SelectedValue != "-1") contact = Convert.ToInt32(lstContact.SelectedValue);
JobOffer offer = log.Company.AddOffer(txtTitle.Text, txtDescription.Text, region, contact);
Response.Redirect(string.Format("joboffer.aspx?id={0}", offer.ID));
}
}
#endregion
}