private void RenderSingleItem(StringBuilder sb, VendorManufacturer vm) { string destinationLink = "Vendors_edit.aspx?id=" + vm.Bvin + "&page=" + currentPage + "&keyword=" + System.Web.HttpUtility.UrlEncode(keyword); string deleteLink = destinationLink.Replace("_edit", "_delete"); sb.Append("<tr><td><a href=\"" + destinationLink + "\">" + vm.DisplayName + "</a></td>"); sb.Append("<td><a href=\"" + destinationLink + "\">" + vm.EmailAddress + "</a></td>"); sb.Append("<td><a onclick=\"return window.confirm('Delete this item?');\" href=\"" + deleteLink + "\" class=\"btn\"><b>Delete</b></a></td>"); sb.Append("<td><a href=\"" + destinationLink + "\" class=\"btn\"><b>Edit</b></a></td></tr>"); }
// Create or Update public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata) { string data = string.Empty; string bvin = FirstParameter(parameters); ApiResponse<VendorManufacturerDTO> response = new ApiResponse<VendorManufacturerDTO>(); VendorManufacturerDTO postedItem = null; try { postedItem = MerchantTribe.Web.Json.ObjectFromJson<VendorManufacturerDTO>(postdata); } catch(Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return MerchantTribe.Web.Json.ObjectToJson(response); } VendorManufacturer item = new VendorManufacturer(); item.FromDto(postedItem); if (bvin == string.Empty) { if (MTApp.ContactServices.Vendors.Create(item)) { bvin = item.Bvin; } } else { MTApp.ContactServices.Vendors.Update(item); } VendorManufacturer resultCategory = MTApp.ContactServices.Vendors.Find(bvin); if (resultCategory != null) response.Content = resultCategory.ToDto(); data = MerchantTribe.Web.Json.ObjectToJson(response); return data; }
private bool Save() { bool result = false; VendorManufacturer m = MTApp.ContactServices.Manufacturers.Find(this.BvinField.Value); if (m == null) m = new VendorManufacturer(); m.DisplayName = this.DisplayNameField.Text.Trim(); m.EmailAddress = this.EmailField.Text.Trim(); m.Address = this.AddressEditor1.GetAsAddress(); m.DropShipEmailTemplateId = this.EmailTemplateDropDownList.SelectedValue; if (this.BvinField.Value == string.Empty) { result = MTApp.ContactServices.Manufacturers.Create(m); } else { result = MTApp.ContactServices.Manufacturers.Update(m); } if (result == false) { this.lblError.Text = "Unable to save manufacturer. Uknown error."; } else { // Update bvin field so that next save will call updated instead of create this.BvinField.Value = m.Bvin; } return result; }
private void LoadGroups(VendorManufacturer m) { MemberList.DataSource = m.Contacts; MemberList.DataValueField = "bvin"; MemberList.DataTextField = "Username"; MemberList.DataBind(); }