public ModelResponse Apply(UserInfo user, long id, string fileFolder, string appForm, List <CodeSet> attachments) { try { if (attachments == null) { attachments = new List <CodeSet>(); } //Authorization if (!IsAuthorized(user, true)) { return(new ModelResponse(101)); } //Verify File Paths if (fileFolder.HasNoValue()) { return(new ModelResponse(102)); } if (!appForm.HasNoValue() && !File.Exists(Path.Combine(fileFolder, appForm))) { return(new ModelResponse(102)); } if (attachments.Any(f => !f.desc.HasNoValue() && !File.Exists(Path.Combine(fileFolder, f.desc)))) { return(new ModelResponse(102)); } //Validations var req = Repo.ApplicationRequirements(id); if (req == null) { return(new ModelResponse(101)); } if (!((String)req["AppTemplate"]).HasNoValue() && appForm.HasNoValue()) { return(new ModelResponse(1)); } if (((List <CodeSet>)req["AdditionalDocs"]).Any(f => attachments.All(a => a.id != f.id || a.desc.HasNoValue()))) { return(new ModelResponse(1)); } //Record Application var ret = Repo.Apply(id, (long)user.PortalUserId, appForm, attachments); if (!ret) { return(new ModelResponse(2)); } } catch (Exception ex) { return(new ModelResponse(ex)); } return(new ModelResponse(0, true)); }