public ActionResult SaveProduct(CreateNewProductViewModel saveDto) { try { using (var dbContext = new TicketCodeTestDBContext()) { var efProduct = new Tproduct(); efProduct.Id = UniqueGenerator.UniId(); efProduct.Name = saveDto.productname; efProduct.Title = saveDto.title; efProduct.Class1 = saveDto.class1; efProduct.Class2 = saveDto.class2; efProduct.DeliveryArea = saveDto.deliveryarea; efProduct.SupplierId = saveDto.supplier; efProduct.Cost = saveDto.cost; efProduct.SalePrice = saveDto.saleprice; efProduct.AvailableStock = saveDto.avaliablestock; efProduct.Description = saveDto.description; dbContext.Tproduct.Add(efProduct); dbContext.SaveChanges(); } return(Json(new { success = true })); } catch (Exception ex) { return(Json(new { success = false, msg = ex.ToString() })); } }
void InitalizeProperties(string name, string mimeType, string id) { if (string.IsNullOrWhiteSpace(id)) { id = string.Format("P_{0}", UniqueGenerator.MakeUnique()); } Name = name; MimeType = mimeType; Id = id; }
/// <summary> /// Initialize the properties. /// </summary> /// <param name="document"></param> /// <param name="name"></param> /// <param name="id"></param> public void InitalizeProperties(XDocument document, string name, string id) { if (string.IsNullOrWhiteSpace(id)) { id = string.Format("P_{0}", UniqueGenerator.MakeUnique()); } Name = name; MimeType = document.MimeType(); Id = id; Document = document; }
/// <summary> /// Initialize the properties. /// </summary> /// <param name="ticket"></param> /// <param name="name"></param> /// <param name="id"></param> public void InitalizeProperties(Ticket ticket, string name, string id) { if (string.IsNullOrWhiteSpace(id)) { id = string.Format("P_{0}", UniqueGenerator.MakeUnique()); } Name = name; MimeType = ticket.MimeType(); Id = id; Ticket = ticket; }
/// <summary> /// Initialize the properties. /// </summary> /// <param name="message"></param> /// <param name="name"></param> /// <param name="id"></param> public void InitalizeProperties(Message message, string name, string id) { if (string.IsNullOrWhiteSpace(id)) { id = string.Format("P_{0}", UniqueGenerator.MakeUnique()); } Name = name; MimeType = message.MimeType(); Id = id; Message = message; }
static void Main(string[] args) { UniqueGenerator ug = new UniqueGenerator(1, 1, 1); for (int i = 0; i < 1000; i++) { Console.WriteLine(ug.GetNextId()); } CalculationDetail(ug.GetNextId()); Console.WriteLine("end.."); Console.Read(); }
public ActionResult SaveNewSupplier(SupplierCreateNewVM createModel) { try { var efSupplier = new Tsupplier(); var efBill = new Tbill(); efSupplier.Name = createModel.suppliername; efSupplier.Type = createModel.suppliertype; efSupplier.FinanceContactor = createModel.financecontacter; efSupplier.FinancePhone = createModel.financephone; efSupplier.Sender = createModel.deliveryname; efSupplier.SenderPhone = createModel.deliveryphone; efSupplier.CompanyName = createModel.companyname; efSupplier.CompanyAddress = createModel.companyaddress; efSupplier.AfterMarketer = createModel.servicename; efSupplier.AfterMarketPhone = createModel.servicephone; efBill.Id = UniqueGenerator.UniId(); efBill.TaxNumber = createModel.taxpayernumber; efBill.BillHeader = createModel.billheader; efBill.Openbank = createModel.openbank; efBill.BankAccount = createModel.bankaccount; efBill.Name = "供应商开票"; using (var dbContext = new TicketCodeTestDBContext()) { dbContext.Database.BeginTransaction(); dbContext.Tbill.Add(efBill); dbContext.Tsupplier.Add(efSupplier); dbContext.SaveChanges(); dbContext.Database.CommitTransaction(); } return(Json(new { success = true, msg = "保存成功" })); } catch (Exception ex) { return(Json(new { success = false, msg = ex.ToString() })); } }
/// <summary> /// Creates a unique id suitable for use as a resource id, job id etc. /// </summary> /// <param name="prefix">The prefix. (optional)</param> /// <returns>A unique id that starts with the prefix</returns> public static string CreateUniqueId(string prefix = "R_") { return(prefix + UniqueGenerator.MakeUnique()); }