public async Task Execute(UpdateLayout command) { var layout = await writeContext.SurveyLayout .Include(l => l.SurveyLayoutQuestion) .Include(l => l.SurveyLayoutTag) .FirstOrDefaultAsync(l => l.UID == command.LayoutId); if (layout == null) { throw new EntityNotFoundException(typeof(SurveyLayout), command.LayoutId); } var currentTags = CreateTags(layout.UID, command.Tags); //delete layout.SurveyLayoutTag .Where(tag => !currentTags.Any(t => tag.DsTag == t.DsTag)) .ToList() .ForEach(tag => layout.SurveyLayoutTag.Remove(tag)); //add currentTags .Where(tag => !layout.SurveyLayoutTag.Any(t => t.DsTag == tag.DsTag)) .ToList() .ForEach(tag => layout.SurveyLayoutTag.Add(tag)); var currentQuestions = GetAllQuestions(layout.UID, command.Items); //delete layout.SurveyLayoutQuestion .Where(question => !currentQuestions.Any(q => q.IdQuestion == question.IdQuestion)) .ToList() .ForEach(question => layout.SurveyLayoutQuestion.Remove(question)); //add currentQuestions .Where(question => !layout.SurveyLayoutQuestion.Any(q => q.IdQuestion == question.IdQuestion)) .ToList() .ForEach(question => layout.SurveyLayoutQuestion.Add(question)); //blank out the question text and choices before serializing the questions command.Items .GetAll(LayoutItemType.Question) .ToList() .ForEach(question => { question.Text = string.Empty; question.Choices = null; }); layout.JsLayout = JsonConvert.SerializeObject(command.Items); layout.NmLayout = command.LayoutName; await writeContext.SaveChangesAsync(); }
public async Task <IActionResult> PutLayout([FromBody] UpdateLayout command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await service.Execute(command); return(Ok()); }
// Singleton private void Awake() { if (instance != null && instance != this) { Destroy(gameObject); } else { instance = this; } }
public void UpdateMyLayout(FlowLayoutPanel llayout) { UpdateLayout ulayout = new UpdateLayout(this.OnUpdateLayout); layout.Invoke(ulayout, new Object[] { llayout }); }
private void OnUpdateLayout() { UpdateLayout?.Invoke(); }