// GET /api/form/5 public FieldNewModel Get(int fieldId, string username, string password) { AccountNewModel account = MyAuthentication.authentication(username, password); FieldNewModel model = new FieldNewModel{ IsAuthenticated = account.IsAuthenticated, Roles = account.Roles }; if (account.IsAuthenticated) { model = db.Fields.Where(m => m.FieldId == fieldId).Select(m => new FieldNewModel { IsAuthenticated = account.IsAuthenticated, Roles = account.Roles, Data = m.Data, FieldColumn = m.FieldColumn, FieldId = m.FieldId, FieldOrder = m.FieldOrder, FieldTypeId = m.FieldTypeId, FormId = m.FormId, Name = m.Name, Required = m.Required }).SingleOrDefault(); model.Selections = new List<FieldTypeModel>(db.FieldTypes.Select(n => new FieldTypeModel { FieldTypeId = n.FieldTypeId, Name = n.Name })); } return model; }
public FieldNewModel Get(string data,string fieldColumn,int? fieldOrder,int? fieldTypeId,int formId,string name,bool required, string username, string password) { AccountNewModel account = MyAuthentication.authentication(username, password); FieldNewModel model = new FieldNewModel { IsAuthenticated = account.IsAuthenticated, Roles = account.Roles, FormId = formId }; if (account.IsAuthenticated) { Field field = new Field{ Data = data, FieldColumn = fieldColumn, FieldOrder = 0, FieldTypeId = 0, FormId = formId, Name = name, Required = required }; if (fieldTypeId.HasValue) field.FieldTypeId = fieldTypeId.Value; if (fieldOrder.HasValue) field.FieldOrder = fieldOrder.Value; db.Fields.Add(field); db.SaveChanges(); } return model; }
public FieldNewModel Get(string data, string fieldColumn, int? fieldOrder, int? fieldTypeId, int formId, int fieldId, string name, bool required, string username, string password) { AccountNewModel account = MyAuthentication.authentication(username, password); FieldNewModel model = new FieldNewModel { IsAuthenticated = account.IsAuthenticated, Roles = account.Roles }; if (account.IsAuthenticated) { Field field = db.Fields.Where(m => m.FieldId == fieldId).SingleOrDefault(); field.FieldColumn = fieldColumn; field.Data = data; field.FieldColumn = fieldColumn; field.Name = name; field.Required = required; if (fieldTypeId.HasValue) field.FieldTypeId = fieldTypeId.Value; if (fieldOrder.HasValue) field.FieldOrder = fieldOrder.Value; db.SaveChanges(); } return model; }