public ContestExtended SecureGet(string accessKey, long siteId, long contestId) { try { ContestExtended contest = _contestLib.GetContest(contestId, true); return(contest); } catch (System.Exception ex) { AwapiFaultException awEx = new AwapiFaultException(); awEx.ErrorMessage = ex.Message; if (ex.InnerException != null) { awEx.ErrorMessage = ex.InnerException.Message; } throw new FaultException <AwapiFaultException>(awEx, new FaultReason(awEx.ErrorMessage)); } }
/// <summary> /// /// </summary> /// <param name="contestId"></param> /// <param name="userId"></param> /// <param name="isEnabled"></param> /// <param name="cultureCode"></param> /// <param name="email"></param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="fileId"></param> /// <param name="fileUrl"></param> /// <param name="tel"></param> /// <param name="telType"></param> /// <param name="address"></param> /// <param name="city"></param> /// <param name="province"></param> /// <param name="postalCode"></param> /// <param name="country"></param> /// <returns></returns> public long AddContestEntry(long contestId, long?userId, bool isEnabled, string cultureCode, string email, string firstName, string lastName, string title, string description, long?fileId, string fileUrl, string tel, string telType, string address, string city, string province, string postalCode, string country) { long id = AWAPI_Common.library.MiscLibrary.CreateUniqueId(); ContestExtended contest = GetContest(contestId, true); if (contest == null) { throw new Exception(ErrorLibrary.ErrorMessage(ErrorLibrary.CONTEST.DOES_NOT_EXIST)); } awContestEntry entry = new awContestEntry(); if (String.IsNullOrEmpty(email) || !AWAPI_Common.library.Validation.IsEmail(email)) { throw new Exception(ErrorLibrary.ErrorMessage(ErrorLibrary.CONTEST.EMAIL_REQUIRED)); } if (String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName)) { throw new Exception(ErrorLibrary.ErrorMessage(ErrorLibrary.CONTEST.FIRSTNAME_LASTNAME_REQUIRED)); } entry.contestEntryId = id; entry.contestId = contestId; entry.userId = userId; entry.isEnabled = isEnabled; entry.cultureCode = cultureCode; entry.email = email; entry.firstName = firstName; entry.lastName = lastName; entry.title = title; entry.description = description; entry.fileId = fileId; entry.fileUrl = fileUrl; entry.tel = tel; entry.telType = telType; entry.address = address; entry.city = city; entry.province = province; entry.postalCode = postalCode; entry.country = country; entry.createDate = DateTime.Now; _context.awContestEntries.InsertOnSubmit(entry); _context.SubmitChanges(); AWAPI_BusinessLibrary.library.EmailTemplateLib lib = new EmailTemplateLib(); //SEND EMAIL TO THE MODERATORS -------------------- if (contest.sendEmailToModeratorTemplateId != null && !String.IsNullOrEmpty(contest.sendEmailToModeratorRecipes)) { string link = ""; if (entry.fileId != null) { link = ConfigurationLibrary.Config.adminBaseUrl + "admin/files.aspx?fileid=" + entry.fileId.Value.ToString(); } lib.Send(entry.awContest.sendEmailToModeratorTemplateId.Value, contest.sendEmailToModeratorRecipes, "firstname|" + entry.firstName, "lastname|" + entry.lastName, "link|" + link, "date|" + DateTime.Now.ToString()); } //SEND EMAIL TO THE CONTENDER -------------------- if (contest.sendEmailAfterSubmissionTemplateId != null) { lib.Send(entry.awContest.sendEmailAfterSubmissionTemplateId.Value, entry.email, "firstname|" + entry.firstName, "lastname|" + entry.lastName, "date|" + DateTime.Now.ToString()); } return(id); }