public void PutTax(Tax tax) { var manager = new UserManager(); var user = manager.LoadBySessionKey(SessionId); var taxes = user.Taxes.ToList(); taxes.Add(tax); user.Taxes = taxes; user.Save(); }
protected void btnSaveConfirmed_Click(object sender, EventArgs e) { try { Entities.Tax tax = new Entities.Tax(); tax.ID = Convert.ToInt32(hdTaxId.Value); tax.Name = txtTaxName.Text.Trim(); tax.Percentage = Convert.ToDecimal(txtTaxPercentage.Text); tax.Type = txtTaxType.Text.Trim(); tax.Status = Convert.ToInt32(ddlTaxStatus.SelectedValue); tax.CompanyId = CPublic.GetCompanyID(); tax.CreatedBy = CPublic.GetuserID(); tax.ModifiedBy = CPublic.GetuserID(); OutputMessage result = null; if (tax.ID == 0) { result = tax.Save(); if (result.Success) { Reset(); ClientScript.RegisterStartupScript(this.GetType(), "message", "successAlert('" + result.Message + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + result.Message + "')", true); } } else { result = tax.Update(); if (result.Success) { Reset(); ClientScript.RegisterStartupScript(this.GetType(), "message", "successAlert('" + result.Message + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + result.Message + "')", true); } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + ex.Message + " ')", true); } }