private void btSaveType_Click(object sender, EventArgs e) { if (txtNameType.Text == string.Empty) { txtNameType.Focus(); errorProviderName.SetError(txtNameType, "Can't be empty"); } else if (txtCodeType.Text == string.Empty) { txtCodeType.Focus(); errorProviderCode.SetError(txtCodeType, "Can't be empty"); } if (txtNameType.Text != string.Empty && txtCodeType.Text != string.Empty) { int countType; List <ConferenceTypeModel> listConferanceType = conferanceTypeRepository.getAllTypes(); countType = listConferanceType.Count; ConferenceTypeModel type; for (int i = 0; i < countType; i++) { type = listConferanceType.ElementAt(i); if (ConferanceTypeId != null && ConferanceTypeId == i + 1) { type.ConferenceTypeName = txtNameType.Text; type.ConferenceTypeCode = txtCodeType.Text; conferanceTypeRepository.getType(type); } else { ConferenceTypeModel typeNew = new ConferenceTypeModel(); if (ConferanceTypeId == null) { typeNew.ConferenceTypeCode = " "; typeNew.ConferenceTypeName = " "; ConferanceTypeId = 0; typeNew.ConferenceTypeName = txtNameType.Text; typeNew.ConferenceTypeCode = txtCodeType.Text; conferanceTypeRepository.insertType(typeNew); } } } this.Close(); } }
public IActionResult Post(ConferenceTypeModel conferenceTypeModel) { conferenceType.insertType(conferenceTypeModel); return(Ok(conferenceTypeModel)); }