/// <summary> /// Function to Submit Survey in to database /// </summary> /// <param name="survey"></param> /// <param name="userId"></param> /// <param name="eventCode"></param> /// <returns></returns> public bool CreateSurvey(SurveyViewModel survey, string userId, string eventCode) { try { //Get EventCd var eventCd = _context.MstEvents.Where(x => x.Code == eventCode && !x.IsDeleted).Select(x => x.Cd).FirstOrDefault(); //Create new Survey object var entity = new Survey { EventCd = eventCd, MediaCd = survey.MediaCd, VisitTime = survey.VisitTime, AgeRange = survey.AgeRange, Gender = survey.Gender == (int)Constants.Gender.Male, CareerCd = survey.CareerCd, IsMarried = survey.IsMarried == (int)Constants.IsMarried.Yes, LivingStatus = survey.LivingStatus == (int)Constants.LivingStatus.Alone, IsComeToBuy = survey.IsComeToBuy == (int)Constants.IsComeToBuy.Yes, FavoriteArtist = survey.FavoriteArtist, //IsDeleted = Convert.ToBoolean(Constants.IsDeleted.No), //UpdateDate = DateTime.Now, //UpdateUserId = userId, InsertDate = DateTime.Now, InsertUserId = userId, SurveyArtists = AddListFavoriteArtists(survey), }; //Add new survey into database _context.Surveys.Add(entity); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }