public IActionResult SaveFeedbackTypeSetting([FromBody] FeedbackTypeSettingDto clientFeedbackTypeSetting) { ClientFeedbackTypeSetting setting = this._feedbackSettingService.FindWithId(clientFeedbackTypeSetting.ClientFeedbackTypeSettingId); if (setting != null) { setting = MapToEntity(clientFeedbackTypeSetting, setting); } else { setting = MapToEntity(clientFeedbackTypeSetting, new ClientFeedbackTypeSetting()); } return(Ok(this._feedbackSettingService.SaveClientFeedbackTypeSetting(setting))); }
private ClientFeedbackTypeSetting MapToEntity(FeedbackTypeSettingDto dto, ClientFeedbackTypeSetting entity) { entity.ResendUrl = dto.ResendUrl; entity.ClientFeedbackTypeId = dto.ClientFeedbackTypeId; if (dto.KeyValues != null) { entity.KeyValues = dto.KeyValues.Select(kv => new KeyValue { Key = kv.Key, Value = kv.Value }).ToList(); } return(entity); }
public ClientFeedbackTypeSetting SaveClientFeedbackTypeSetting(ClientFeedbackTypeSetting clientFeedbackTypeSetting) { if (clientFeedbackTypeSetting.ClientFeedbackTypeSettingId == 0) { var savedEntity = this._sfsDbContext.ClientFeedbackTypeSettings.Add(clientFeedbackTypeSetting); this._sfsDbContext.SaveChanges(); return(savedEntity.Entity); } else { var savedEntity = this._sfsDbContext.ClientFeedbackTypeSettings.Update(clientFeedbackTypeSetting); this._sfsDbContext.SaveChanges(); return(savedEntity.Entity); } }