public static void AddDefaultFeids(int EventID, DAL dalDataContext) { List<Field> ListField = new List<Field>(); Field firstName = new Field(); firstName.FieldName = firstName.FieldLabel = "First Name"; Field lastName = new Field(); lastName.FieldName = lastName.FieldLabel = "Last Name"; firstName.IsRequired = lastName.IsRequired = true; Field email = new Field(); email.FieldName = email.FieldLabel = "Email"; email.IsRequired = email.IsRequired = true; ListField.Add(firstName); ListField.Add(lastName); ListField.Add(email); try { for (int i = 0; i < ListField.Count; i++) { AddField(dalDataContext, EventID, ListField[i]); } dalDataContext.SubmitChanges(); } catch (Exception ex) { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Field, Please Try Again!")); } }
public ExportData(Events evnt, EventDay[] days, Task[] tasks, FacilityBookingConfirmed[][] facilities, Program[][] programs, Guest[][] guests, Participant[] participants , OptimizedBudgetItems optitems, BudgetIncome[] budgetincomes, Field[] field) { this.evnts = evnt; this.days = days; this.tasks = tasks; this.facilities = facilities; this.programs = programs; this.guests = guests; this.participants = participants; this.optitems = optitems; this.budgetincomes = budgetincomes; this.field = field; }
//public static void AddField(User user, int EventID, string FieldLabel, string FieldName, string Remarks, bool IsRequired) //{ // if (!u.isAuthorized(EventController.GetEvent(EventID))) // throw new FaultException<SException>(new SException(), // new FaultReason("Invalid User, User Does Not Have Rights To Add Field!")); // try // { // //Event evnt = EventController.GetEvent(EventID); // //if(e == null) // // throw new FaultException<SException>(new SException(), // // new FaultReason("Invalid Event ID")); // DAL dalDataContext = new DAL(); // Table<Field> fields = dalDataContext.fields; // Field creatingField = new Field(Remarks, FieldLabel, FieldName, EventID, IsRequired); // fields.InsertOnSubmit(creatingField); // fields.Context.SubmitChanges(); // } // catch // { // throw new FaultException<SException>(new SException(), // new FaultReason("An Error occured While Adding New Field, Please Try Again!")); // } //} public static void AddField(DAL dalDataContext, int EventID, Field incField) { try { Table<Field> fields = dalDataContext.fields; Field creatingField = new Field(incField.Remarks, incField.FieldLabel, incField.FieldName, EventID, incField.IsRequired); fields.InsertOnSubmit(creatingField); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Field, Please Try Again!")); } }