| 1065 | |
| 1066 | '''Прототип на апликацијата направена со Naked Objects во ASP.Net''' |
| 1067 | |
| 1068 | '''User.cs''' |
| 1069 | {{{ |
| 1070 | #!c# |
| 1071 | using NakedObjects; |
| 1072 | using System; |
| 1073 | using System.Collections.Generic; |
| 1074 | using System.ComponentModel.DataAnnotations; |
| 1075 | using System.Linq; |
| 1076 | using System.Text; |
| 1077 | using System.Threading.Tasks; |
| 1078 | |
| 1079 | namespace CoDBIS_NakedObjects |
| 1080 | { |
| 1081 | public class User |
| 1082 | { |
| 1083 | public override string ToString() |
| 1084 | { |
| 1085 | return Name; |
| 1086 | } |
| 1087 | |
| 1088 | |
| 1089 | [Hidden] |
| 1090 | public virtual int Id { get; set; } |
| 1091 | |
| 1092 | [StringLength (50)] |
| 1093 | public virtual string Name { get; set; } |
| 1094 | |
| 1095 | |
| 1096 | public virtual string Gender { get; set; } |
| 1097 | |
| 1098 | |
| 1099 | public virtual string PlaceOfBirth { get; set; } |
| 1100 | |
| 1101 | [Mask("d")] |
| 1102 | public virtual DateTime DateOfBirth { get; set; } |
| 1103 | |
| 1104 | |
| 1105 | public virtual string Email { get; set; } |
| 1106 | |
| 1107 | |
| 1108 | public virtual string Employer { get; set; } |
| 1109 | |
| 1110 | |
| 1111 | public virtual string Position { get; set; } |
| 1112 | |
| 1113 | public IDomainObjectContainer Container { set; protected get; } |
| 1114 | |
| 1115 | |
| 1116 | #region AddActivity (collection) |
| 1117 | private ICollection<AddUserOnActivity> _AddActivity = new List<AddUserOnActivity>(); |
| 1118 | |
| 1119 | public virtual ICollection<AddUserOnActivity> AddActivity |
| 1120 | { |
| 1121 | get |
| 1122 | { |
| 1123 | return _AddActivity; |
| 1124 | } |
| 1125 | set |
| 1126 | { |
| 1127 | _AddActivity = value; |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | public void AddToAddActivity(AddUserOnActivity value) |
| 1132 | { |
| 1133 | if (!(_AddActivity.Contains(value))) |
| 1134 | { |
| 1135 | _AddActivity.Add(value); |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | public void RemoveFromAddActivity(AddUserOnActivity value) |
| 1141 | { |
| 1142 | if (_AddActivity.Contains(value)) |
| 1143 | { |
| 1144 | _AddActivity.Remove(value); |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | public IList<AddUserOnActivity> Choices0RemoveFromAddActivity() |
| 1149 | { |
| 1150 | return _AddActivity.ToList(); |
| 1151 | } |
| 1152 | #endregion |
| 1153 | |
| 1154 | public AddUserOnActivity CreateNewUserOnActivity() //CreateNewOrder od tip Order |
| 1155 | { |
| 1156 | |
| 1157 | var order = Container.NewTransientInstance<AddUserOnActivity>(); |
| 1158 | order.User = this; |
| 1159 | return order; |
| 1160 | } |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | public AddUserOnActivity CreateNewAddUserOnActivity() |
| 1166 | { |
| 1167 | AddUserOnActivity obj = Container.NewTransientInstance<AddUserOnActivity>(); |
| 1168 | |
| 1169 | obj.User = this; |
| 1170 | return obj; |
| 1171 | } |
| 1172 | |
| 1173 | |
| 1174 | |
| 1175 | } |
| 1176 | } |
| 1177 | }}} |
| 1178 | |
| 1179 | '''Activity.cs''' |
| 1180 | {{{ |
| 1181 | #!c# |
| 1182 | using NakedObjects; |
| 1183 | using System; |
| 1184 | using System.Collections.Generic; |
| 1185 | using System.ComponentModel.DataAnnotations; |
| 1186 | using System.Linq; |
| 1187 | using System.Text; |
| 1188 | using System.Threading.Tasks; |
| 1189 | |
| 1190 | namespace CoDBIS_NakedObjects |
| 1191 | { |
| 1192 | public class Activity |
| 1193 | { |
| 1194 | public override string ToString() |
| 1195 | { |
| 1196 | return Name; |
| 1197 | } |
| 1198 | |
| 1199 | [Hidden] |
| 1200 | public virtual int Id { get; set; } |
| 1201 | |
| 1202 | |
| 1203 | [StringLength (50), Title] |
| 1204 | public virtual string Name { get; set; } |
| 1205 | |
| 1206 | |
| 1207 | public virtual string Place { get; set; } |
| 1208 | |
| 1209 | // [Title, Mask("d")] |
| 1210 | public virtual DateTime Date { get; set; } |
| 1211 | |
| 1212 | |
| 1213 | public virtual string Category { get; set; } |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | |
| 1221 | } |
| 1222 | } |
| 1223 | }}} |
| 1224 | |
| 1225 | '''Activityhistory.cs''' |
| 1226 | {{{ |
| 1227 | #!c# |
| 1228 | using NakedObjects; |
| 1229 | using System; |
| 1230 | using System.Collections.Generic; |
| 1231 | using System.ComponentModel; |
| 1232 | using System.Linq; |
| 1233 | using System.Text; |
| 1234 | using System.Threading.Tasks; |
| 1235 | |
| 1236 | namespace CoDBIS_NakedObjects |
| 1237 | { |
| 1238 | public class ActivityHistory |
| 1239 | { |
| 1240 | |
| 1241 | public override string ToString() |
| 1242 | { |
| 1243 | return Role.ToString() + " на " + Activity; |
| 1244 | } |
| 1245 | |
| 1246 | [Hidden] |
| 1247 | public virtual int Id { get; set; } |
| 1248 | |
| 1249 | [Hidden] |
| 1250 | public virtual AddUserOnActivity AddUserOnActivity { get; set; } |
| 1251 | |
| 1252 | |
| 1253 | public virtual Activity Activity { get; set; } |
| 1254 | |
| 1255 | [DefaultValue("")] |
| 1256 | public virtual string Role { get; set; } |
| 1257 | |
| 1258 | } |
| 1259 | } |
| 1260 | }}} |
| 1261 | |
| 1262 | '''Adduseronactivity.cs''' |
| 1263 | {{{ |
| 1264 | #!c# |
| 1265 | using NakedObjects; |
| 1266 | using System; |
| 1267 | using System.Collections.Generic; |
| 1268 | using System.Linq; |
| 1269 | using System.Text; |
| 1270 | using System.Threading.Tasks; |
| 1271 | |
| 1272 | namespace CoDBIS_NakedObjects |
| 1273 | { |
| 1274 | public class AddUserOnActivity |
| 1275 | { |
| 1276 | |
| 1277 | public override string ToString() |
| 1278 | { |
| 1279 | return User.ToString(); |
| 1280 | } |
| 1281 | |
| 1282 | [Hidden] |
| 1283 | public virtual int Id { get; set; } |
| 1284 | |
| 1285 | [Disabled] |
| 1286 | public virtual User User { get; set; } |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | #region History (collection) |
| 1291 | private ICollection<ActivityHistory> _History = new List<ActivityHistory>(); |
| 1292 | |
| 1293 | public virtual ICollection<ActivityHistory> History |
| 1294 | { |
| 1295 | get |
| 1296 | { |
| 1297 | return _History; |
| 1298 | } |
| 1299 | set |
| 1300 | { |
| 1301 | _History = value; |
| 1302 | } |
| 1303 | } |
| 1304 | |
| 1305 | public void AddToHistory(ActivityHistory value) |
| 1306 | { |
| 1307 | if (!(_History.Contains(value))) |
| 1308 | { |
| 1309 | _History.Add(value); |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | public void RemoveFromHistory(ActivityHistory value) |
| 1314 | { |
| 1315 | if (_History.Contains(value)) |
| 1316 | { |
| 1317 | _History.Remove(value); |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | public IList<ActivityHistory> Choices0RemoveFromHistory() |
| 1322 | { |
| 1323 | return _History.ToList(); |
| 1324 | } |
| 1325 | #endregion |
| 1326 | |
| 1327 | |
| 1328 | public IDomainObjectContainer Container { set; protected get; } |
| 1329 | |
| 1330 | |
| 1331 | public ActivityHistory AddToHistory() |
| 1332 | { |
| 1333 | |
| 1334 | var history = Container.NewTransientInstance<ActivityHistory>(); |
| 1335 | history.AddUserOnActivity = this; |
| 1336 | return history; |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | public ActivityHistory CreateNewActivityHistory() |
| 1341 | { |
| 1342 | ActivityHistory obj = Container.NewTransientInstance<ActivityHistory>(); |
| 1343 | |
| 1344 | obj.AddUserOnActivity = this; |
| 1345 | return obj; |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | } |
| 1351 | } |
| 1352 | }}} |
| 1353 | |