private void btnSave_Click(object sender, EventArgs e) { using (TransactionScope transactionScope = new TransactionScope()) { if (newProfile == "New") { if (checkprofilename()) { var userProfile = new UserProfileModel() { ProfileName = txtProfileName.Text, ProfileDesc = txtdesc.Text, CreatedDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), CreatedBy = 1, }; ProfileId = _userProfileService.SaveUserprofile(userProfile); newProfile = ""; } } else { ProfileId = (int)CmbProfile.SelectedValue; var data = datafunc(); _userProfileService.DeleteUserDetail(ProfileId); _userProfileService.SaveUserProfileDetaile(data); RadMessageBox.Show("Saved", "Profile Entry", MessageBoxButtons.OK); Notify(); txtProfileName.Visible = false; CmbProfile.Visible = true; txtdesc.Text = ""; } transactionScope.Complete(); } var data1 = _userProfileService.GetProfiledataByProfileId(ProfileId); RadGridProfile.DataSource = data1; }
public int SaveUserprofile(UserProfileModel model) { try { using (_context = new HSSNInventoryEntities()) { var data = new UserProfile() { ProfileId = model.ProfileId, ProfileName = model.ProfileName, ProfileDesc = model.ProfileDesc, CreatedDate = model.CreatedDate, CreatedBy = model.CreatedBy, }; _context.Entry(data).State = EntityState.Added; _context.SaveChanges(); return data.ProfileId; } } catch (Exception) { throw; } }