public List <Category> getAllCategories() { List <Category> lstCategory = new EFCategory().getAllCategories(); foreach (var item in lstCategory) { item.ImageURL = AppConfigSetting.CategoryUrl.ToString() + item.CategoryId.ToString() + item.ImageURL; } return(lstCategory); }
protected void btnSave_Click(object sender, EventArgs e) { Category category = formToObject(); bool result = new EFCategory().saveCategory(ref category, ref ErrorMessage, SessionHelper.getUserSession().userid); if (result) { saveImage(category.CategoryId); lblMessage.Text = ""; FormReset(); FormLoad(); MisOp.ShowMessage(this, "The Record has been saved", "Contact Person ", true); //return; } else { lblMessage.Text = ErrorMessage; } }
public ActionResponse Add(Category newCategory) { try { using (var scope = new TransactionScope()) { var Category = new EFCategory() { Name = newCategory.Name }; unitWork.CategoryRepository.Insert(Category); unitWork.Save(); scope.Complete(); response.Success = true; response.ReturnedId = Category.Id; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
//Не ипользуется private void Test() { using (SqliteContext scontext = new SqliteContext()) { EFCategory eFCategory = new EFCategory(dbContext); EFManufacturer eFManufacturer = new EFManufacturer(dbContext); //EFGood eFGood = new EFGood(dbContext); //int count = 0; //int manufacturerId = 0; //Manufacturer manufacturer = null; //int categoryId = 0; //Category category = null; string writePath = @"D:\goods.sql"; using (StreamWriter sw = new StreamWriter(writePath, false, System.Text.Encoding.UTF8)) { foreach (var good in scontext.Goods) { //if (count >= 10) break; sw.WriteLine(@"" + "INSERT [dbo].[Goods] " + "([DataSheetUrl], " + "[Description], " + "[ImagePath]," + "[ManufacturerPartNumber]," + "[Min]," + "[Mult]," + "[MouserPartNumber]," + "[ProductDetailUrl]," + "[Reeling]," + "[ROHSStatus]," + "[Category_Id]," + "[Manufacturer_Id]) " + "VALUES (" + "N'" + good.DataSheetUrl + "', " + "N'" + good.Description.Replace("'", "") + "', " + "N'" + good.ImagePath + "'," + "N'" + good.ManufacturerPartNumber + "'," + good.Min + "," + good.Mult + "," + "N'" + good.MouserPartNumber + "'," + "N'" + good.ProductDetailUrl + "'," + "'" + good.Reeling + "'," + "N'" + good.ROHSStatus + "'," + good.CategoryId + "," + good.ManufacturerId + ")"); //count++; } } //foreach (var good in scontext.Goods) //{ //if (good.ManufacturerId != manufacturerId) //{ // manufacturerId = good.ManufacturerId; // manufacturer = await eFManufacturer.FindByIdAsync(good.ManufacturerId); //} //if (good.CategoryId != categoryId) //{ // categoryId = good.CategoryId; // category = await eFCategory.FindByIdAsync(good.CategoryId); //} //dbContext.Goods.Add(new Domain.Entities.Good //{ // Category = category, // Manufacturer = manufacturer, // DataSheetUrl = good.DataSheetUrl, // Description = good.Description, // ImagePath = good.ImagePath, // ManufacturerPartNumber = good.ManufacturerPartNumber, // Min = good.Min, // MouserPartNumber = good.MouserPartNumber, // Mult = good.Mult, // ProductDetailUrl = good.ProductDetailUrl, // Reeling = good.Reeling, // ROHSStatus = good.ROHSStatus //}); //count++; //if (count % 1000 == 0) //{ // await dbContext.SaveChangesAsync(); //} //await eFGood.AddOrUpdateAsync(new Domain.Entities.Good //{ // Category = await eFCategory.FindByIdAsync(good.CategoryId), // Manufacturer = await eFManufacturer.FindByIdAsync(good.ManufacturerId), // DataSheetUrl = good.DataSheetUrl, // Description = good.Description, // ImagePath = good.ImagePath, // ManufacturerPartNumber = good.ManufacturerPartNumber, // Min = good.Min, // MouserPartNumber = good.MouserPartNumber, // Mult = good.Mult, // ProductDetailUrl = good.ProductDetailUrl, // Reeling = good.Reeling, // ROHSStatus = good.ROHSStatus //}, -1); //} //await dbContext.SaveChangesAsync(); MessageBox.Show("Готово"); //EFGood eFGood = new EFGood(dbContext); //foreach(var good in scontext.Goods) //{ // var dd = good; //} } }