public ActionResult Create(table1 table1) { if (ModelState.IsValid) { db.table1.Add(table1); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(table1)); }
//增加 public void Add(string Introduce, string Describe) { TableTest tableTestAdd = new TableTest(); tableTestAdd.Id = Guid.NewGuid().ToString("N"); tableTestAdd.Introduce = Introduce; tableTestAdd.Describe = Describe; tableTestAdd.AddTime = DateTime.Now; _context.Set <TableTest>().Add(tableTestAdd); _context.SaveChanges(); }
public string ImportCustomer() { string rootFolder = @"C:\Users\Yulia\Desktop\VeloAPI\resours\Import\"; string fileName = $"ImportHelthStatus{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"; FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Статус здоровья"]; workSheet.Cells[1, 1].Value = "Статус здоровья"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; int totalRows = workSheet.Dimension.Rows; List <HelthStatus> customerList = new List <HelthStatus>(); for (int i = 2; i <= totalRows; i++) { customerList.Add(new HelthStatus { NameHealth = workSheet.Cells[i, 1].Value.ToString(), }); } _context.HelthStatus.AddRange(customerList); _context.SaveChanges(); return("Файл успешно импортирован"); } }
public string PackageDeliver(string ComponentType, int count) { string deliveryCharge = ""; ProcessRequest processRequest = new ProcessRequest(); processRequest.ComponentType = ComponentType; processRequest.Quantity = count; if (ComponentType == "Integral") { int amount = 100; count = Convert.ToInt32(count); int delcharge = 200; deliveryCharge = Convert.ToString((amount * count) + delcharge); } if (ComponentType == "Accessory") { int amount = 50; count = Convert.ToInt32(count); int delcharge = 100; deliveryCharge = Convert.ToString((amount * count) + delcharge); } _context.SaveChanges(); return(deliveryCharge); }
/// <summary> /// 增加一个用户数据 /// </summary> /// <param name="model"></param> public static User.AddUserR AddUser(User model) { var r = new User.AddUserR(); var userSearch = db.User .Where(b => b.Name == model.Name); if (userSearch.Count() == 0) { User user = new User(); user.Name = model.Name; user.Pwd = model.Pwd; db.User.Add(user); int i = db.SaveChanges(); if (i > 0) { r.code = 1; r.message = "数据插入成功"; } else { r.code = 0; r.message = "数据插入成功"; } } else { r.code = 0; r.message = "手机号已经存在"; } return(r); }
public Model.Users Register(Model.Users request) { if (request.Password != request.PassworConfirm) { throw new Exception("Passwords don't match"); } Database.Users user = _mapper.Map <Database.Users>(request); user.PasswordSalt = HashGenerator.GenerateSalt(); user.PasswordHash = HashGenerator.GenerateHash(user.PasswordSalt, request.Password); _context.Users.Add(user); _context.SaveChanges(); return(_mapper.Map <Model.Users>(user)); }
public string ImportCustomer() { string rootFolder = @"C:\Users\Yulia\Desktop\VeloAPI\resours\Import\"; string fileName = $"ImportCategoriYars{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"; FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Категория возраста участника"]; workSheet.Cells[1, 1].Value = "Категория возраста участника"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:B1"].Merge = true; int totalRows = workSheet.Dimension.Rows; List <CategoriYars> customerList = new List <CategoriYars>(); for (int i = 2; i <= totalRows; i++) { customerList.Add(new CategoriYars { Ot = (short)workSheet.Cells[i, 1].Value, Do = (short)workSheet.Cells[i, 1].Value, }); } _context.CategoriYars.AddRange(customerList); _context.SaveChanges(); return("Файл успешно импортирован"); } }
//Funciòn solo para test, en BD InMemory private void DataTestMemory(testContext context) { context.DbUsuarios.Add(new Usuarios { Registro = "C100020", Nombres = "Kristian Espitia", Clave = "12345", EsAdministrador = "N" }); context.DbUsuarios.Add(new Usuarios { Registro = "C100021", Nombres = "Juan Cardona", Clave = "12345", EsAdministrador = "S" }); context.DbCategorias.Add(new Categorias { Nombre = "HSE" }); context.DbCategorias.Add(new Categorias { Nombre = "Salud" }); context.DbPreguntas.Add(new Preguntas { CategoriaId = 1, Activa = "S", Pregunta = "Si tengo contrato de trabajo con Ecopetrol, ¿a partir de qué momento puedo empezar a hacer uso de los servicios de Salud?", Respuesta = "Desde el día en que ingresa a la compañía con un contrato de trabajado firmado con Ecopetrol se convierte en beneficiario del Plan de Salud y podrá hacer uso de los servicios presentando la cédula" }); context.DbPreguntas.Add(new Preguntas { CategoriaId = 1, Activa = "S", Pregunta = "¿Cómo inscribo a mis familiares y beneficiarios?", Respuesta = "Usted puede realizar la inscripción o ratificación de sus familiares en las oficinas de personal diligenciando el formato publicado en IRIS y aportando la documentación exigida para cada familiar. Si la documentación es correcta y está completa los nuevos beneficiarios podrán disfrutar de todos los beneficios" }); context.DbPreguntas.Add(new Preguntas { CategoriaId = 2, Activa = "S", Pregunta = "¿Cómo escojo a mi médico de cabecera por primera vez?", Respuesta = "Debe tramitar la selección de su profesional de cabecera: médico general, pediatra, odontólogo general u odontopediatra, según sea el casos ante las dependencias de Servicios de Salud o realizar la solicitud escribiendo al correo [email protected]" }); context.SaveChanges(); }
public async void GetData() { using (HttpClient http = new HttpClient()) { for (int i = 1; i <= 172; i++) { var res = await http.GetAsync($"https://www.shanxi0357.cn/app/index.php?i=124&t=0&v=1.2.19&from=wxapp&c=entry&a=wxapp&do=getLotteryAllList&m=ly_caip&sign=98ce5c18469013c502bfd4849a0212c0&cid=1&page={i}"); var resStr = await res.Content.ReadAsStringAsync(); var appBall = JsonConvert.DeserializeObject <AppBall>(resStr); var balls = appBall.data.Select(d => new Ball { Code = d.code, Date = d.date, R1 = d.red[0], R2 = d.red[1], R3 = d.red[2], R4 = d.red[3], R5 = d.red[4], R6 = d.red[5], B1 = d.blue[0] }); testContext.Ball.AddRange(balls); } testContext.SaveChanges(); }; }
public IActionResult Post([FromBody] Alpha a) { _context.Add(a); _context.SaveChanges(); return(CreatedAtRoute(new { id = a.Id }, a)); }
public string ImportCustomer(string patchname) { string result_msage = ""; int count_i = 0; int count_row = 0; string fileName = patchname; FileInfo file = new FileInfo(Path.Combine(rootFolders, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Пользователи"]; workSheet.Cells[1, 1].Value = "Дистанции"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:C1"].Merge = true; int totalRows = workSheet.Dimension.Rows; count_row = totalRows; List <Distantion> customerList = new List <Distantion>(); for (int i = 3; i <= totalRows; i++) { if (workSheet.Cells[i, 1].Value != null && workSheet.Cells[i, 2].Value != null) { decimal length = Convert.ToDecimal(workSheet.Cells[i, 2].Value); var distantions_test = _context.Distantion.Where(p => p.NameDistantion == workSheet.Cells[i, 1].Value.ToString() && p.Lengs == length); if (distantions_test.Count() == 0) { if (workSheet.Cells[i, 3].Value == null) { workSheet.Cells[i, 3].Value = "Описание отсутствует"; } customerList.Add(new Distantion { NameDistantion = workSheet.Cells[i, 1].Value.ToString(), Lengs = Convert.ToDecimal(workSheet.Cells[i, 2].Value), Discriptions = workSheet.Cells[i, 3].Value.ToString() }); count_i = i - 3; result_msage = "Все строки успешно сохранены, всего" + count_i + " строк"; } } else { result_msage = "Сохранено: " + (count_i) + " строк. " + (count_row - count_i) + " строка не заполнена, проверьте и попробуйте снова"; break; } } _context.Distantion.AddRange(customerList); _context.SaveChanges(); } return(result_msage); }
public IActionResult Add(int idUser, string message) { var user = _context.Users.Where(w => w.IdUser == idUser).FirstOrDefault() ; Message add = new Message { IdUserNavigation = user, DatTime = DateTime.Now, MessageContent = message }; var _res = _context.Message.Add(add); _context.SaveChanges(); return(Ok(_res)); }
public async Task <IdResponse> HandleAsync(DeleteTransporterCommand cmd, CancellationToken ct) { if (cmd.Id.Equals(Guid.Empty)) { return(IdResponse.Unsuccessful("Id is empty")); } var transporter = _transporterRepository.GetById(cmd.id); var result = _transporterRepository.DeleteByT(transporter); var user = _context.Users.Find(cmd.id.ToString()); _context.Users.Remove(user); _context.SaveChanges(); var transporterDeletedEvent = new TransporterDeletedEvent { TransporterId = cmd.id }; _eventRouter.EventAsync(transporterDeletedEvent); return(new IdResponse(cmd.Id)); }
public ActionResult testpage([Bind(Include = "recom_up, recom_down")] testpageModels tests, String up_val, String down_val) { if (up_val != null) { tests.recom_up = up_val; } if (down_val != null) { tests.recom_down = down_val; } db.testdb.Add(tests); db.SaveChanges(); return(View(tests)); }
public string ImportCustomer(string patchname) { string result_msage = ""; int count_i = 0; int count_row = 0; string fileName = patchname; FileInfo file = new FileInfo(Path.Combine(rootFolders, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Пользователи"]; workSheet.Cells[1, 1].Value = "Итоги соревнования"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:C1"].Merge = true; int totalRows = workSheet.Dimension.Rows; count_row = totalRows; List <ResultParticipation> customerList = new List <ResultParticipation>(); for (int i = 3; i <= totalRows; i++) { if (workSheet.Cells[i, 1].Value != null && workSheet.Cells[i, 2].Value != null) { decimal length = Convert.ToDecimal(workSheet.Cells[i, 2].Value); var distantions_test = _context.ResultParticipation.Where(p => p.IdParticipation == Convert.ToInt32(workSheet.Cells[i, 1].Value)); if (distantions_test.Count() == 0) { customerList.Add(new ResultParticipation { IdParticipation = Convert.ToInt32(workSheet.Cells[i, 1].Value), ResultTime = Convert.ToDateTime(workSheet.Cells[i, 1].Value), Mesto = Convert.ToInt32(workSheet.Cells[i, 1].Value), }); count_i = i - 3; result_msage = "Все строки успешно сохранены, всего" + count_i + " строк"; } else { result_msage = "Сохранено: " + (count_i) + " строк. " + (count_row - count_i) + " строка не заполнена, проверьте и попробуйте снова"; break; } } _context.ResultParticipation.AddRange(customerList); _context.SaveChanges(); } } return(result_msage); }
public string ImportCustomer(string patchname) { string result_msage = ""; int count_i = 0; int count_row = 0; string fileName = patchname; FileInfo file = new FileInfo(Path.Combine(rootFolders, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Пользователи"]; workSheet.Cells[1, 1].Value = "Компетенции"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:B1"].Merge = true; int totalRows = workSheet.Dimension.Rows; List <Competentions> customerList = new List <Competentions>(); for (int i = 3; i <= totalRows; i++) { if (workSheet.Cells[i, 1].Value != null && workSheet.Cells[i, 2].Value != null) { customerList.Add(new Competentions { IdDistantion = Convert.ToInt32(workSheet.Cells[i, 1].Value), Date = Convert.ToDateTime(workSheet.Cells[i, 2].Value) }); count_i = i - 3; result_msage = "Все строки успешно сохранены, всего" + count_i + " строк"; } else { result_msage = "Сохранено: " + (count_i) + " строк. " + (count_row - count_i) + " строка не заполнена, проверьте и попробуйте снова"; break; } } _context.Competentions.AddRange(customerList); _context.SaveChanges(); return(result_msage); } }
// GET: api/Mail/5 // [HttpGet("{id}")] public async Task <string> ReplisPassword(int id) { var participant = await _context.UserInfo.FirstOrDefaultAsync(x => x.IdUsers == Convert.ToInt32(id)); if (participant != null) { string password = passwordGenerate.GetPassword(); string hash = passwordGenerate.Get_Password_Two_Autentification(password); EmailService emailService = new EmailService(); emailService.SendEmail(participant.Email, "Восстановление пароля", "Ваш новый пароль: " + password); var customer = _context.UserInfo.Where(c => c.IdUsers == id).FirstOrDefault(); customer.Password = hash; _context.SaveChanges(); return("True"); } return("Fals"); }
/// <summary> /// 测试git提交 v2018.12.14 -002 /// </summary> /// <returns></returns> public IActionResult Index() { //saasoamanagerContext dbContext = new saasoamanagerContext(); //dbContext.Tsysquestiontype.Add(new DataAccessModels.Tsysquestiontype() //{ // Id = 2, // Name = "1", // SystemId = "001", // UserId = 7, // EnterpriseId = 6, // IsDeleted = "0", // IsEnabled = "1", // UtcCreatedDate = DateTime.Now.ToUniversalTime(), // UtcUpdatedDate = DateTime.Now.ToUniversalTime() //}); //dbContext.SaveChanges(); //dbContext.Dispose(); int count = 3; testContext dbMySqlContext = new testContext(); for (int i = 0; i < 30; i++) { dbMySqlContext.Tsysquestiontype.Add(new DBMySQLModels.Tsysquestiontype() { Id = count, Name = count.ToString(), SystemId = "001", //UserId = 7, EnterpriseId = 6, IsDeleted = "0", IsEnabled = "1", UtcCreatedDate = DateTime.Now.ToUniversalTime(), UtcUpdatedDate = DateTime.Now.ToUniversalTime() }); count = count + 1; } dbMySqlContext.SaveChanges(); dbMySqlContext.Dispose(); return(View()); }
public static void Main(string[] args) { using (var db = new testContext()) { // Creating a new item and saving it to the database var newItem = new Item(); newItem.Name = "Red Apple"; newItem.Description = "Description of red apple"; db.Item.Add(newItem); var count = db.SaveChanges(); Console.WriteLine("{0} records saved to database", count); // Retrieving and displaying data Console.WriteLine(); Console.WriteLine("All items in the database:"); foreach (var item in db.Item) { Console.WriteLine("{0} | {1}", item.Name, item.Description); } } }
public string ImportCustomer(string patchname) { FileInfo file = new FileInfo(Path.Combine(rootFolders, patchname)); if (File.Exists(file.ToString())) { File.Delete(file.ToString()); } // file.Open(@"C:\Users\Yulia\Desktop\VeloAPI\resours\Import\"+fileName,FileAccess.Read, FileShare.ReadWrite); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Пользователи"]; workSheet.Cells[1, 1].Value = "Дистанции"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:C1"].Merge = true; int totalRows = workSheet.Dimension.Rows; List <Distantion> customerList = new List <Distantion>(); for (int i = 2; i <= totalRows; i++) { customerList.Add(new Distantion { NameDistantion = workSheet.Cells[i, 1].Value.ToString(), Lengs = Convert.ToDecimal(workSheet.Cells[i, 2].Value), Discriptions = workSheet.Cells[i, 3].Value.ToString() }); } _context.Distantion.AddRange(customerList); _context.SaveChanges(); } return("Файл успешно импортирован"); }
public string ImportCustomer() { string rootFolder = @"C:\Users\Yulia\Desktop\VeloAPI\resours\Import\"; string fileName = $"ImportOfise{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"; FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Офисы"]; workSheet.Cells[1, 1].Value = "Офисы"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:J1"].Merge = true; int totalRows = workSheet.Dimension.Rows; List <Ofise> customerList = new List <Ofise>(); for (int i = 2; i <= totalRows; i++) { customerList.Add(new Ofise { NameOfis = workSheet.Cells[i, 1].Value.ToString(), Descriptio = workSheet.Cells[i, 2].Value.ToString(), TimeOpen = (TimeSpan)workSheet.Cells[i, 3].Value, TimeClouse = (TimeSpan)workSheet.Cells[i, 4].Value, Latitude = workSheet.Cells[i, 5].Value.ToString(), Longitude = workSheet.Cells[i, 6].Value.ToString(), Logo = workSheet.Cells[i, 7].Value.ToString(), }); } _context.Ofise.AddRange(customerList); _context.SaveChanges(); return("Файл успешно импортирован"); } }
static void Main(string[] args) { ////Console.WriteLine("Enter Student Name: "); ////string name = Console.ReadLine(); //string name = "Shubham"; ////Console.WriteLine("Enter Department No"); //int deptNo = 10; ////int deptNo = int.Parse(Console.ReadLine()); ////Console.WriteLine("Enter Email"); ////string email = Console.ReadLine(); //string email = "*****@*****.**"; ////Console.WriteLine("Enter Mobile"); ////string mob = Console.ReadLine(); //string mob = "9988766577"; //Employee ob = new Employee() //{ // DeptNo = deptNo, // Email = email, // EmpId = string.Format("{0}", DateTime.Now.Millisecond.ToString()), // RegDate = DateTime.Now, // EmpName = name, // Mobile = mob //}; //testContext context = new testContext(); //context.Employee.Add(ob); //context.SaveChanges(); //Console.WriteLine("Data inserted successfully"); //context.Dispose(); //Console.ReadKey(); var context = new testContext(); //var data = context.Employee.Where(x => x.DeptNo == 10) // .Include(x => x.DeptNoNavigation) // .ToList(); //foreach(var dt in data) //{ // Console.WriteLine(string.Format("Id : {0}", dt.EmpId)); // Console.WriteLine(string.Format("Employee : {0}", dt.EmpName)); // Console.WriteLine(string.Format("Email : {0}", dt.Email)); // Console.WriteLine(string.Format("Mobile : {0}", dt.Mobile)); // Console.WriteLine(string.Format("Department : {0}", dt.DeptNoNavigation.DeptName)); // Console.WriteLine("--------------------------------------------------------------------"); //} //Console.ReadKey(); //var data = context.Employee.Where(x => x.EmpName == "Shub").FirstOrDefault(); //data.Email = "*****@*****.**"; //context.SaveChanges(); //Console.WriteLine("Changes Updated"); //Console.ReadKey(); var data = new Employee() { EmpId = "1003", DeptNo = 10, EmpName = "Shub", Mobile = "9900887908", RegDate = DateTime.Now, Email = "*****@*****.**" }; context.Update(data); context.SaveChanges(); Console.WriteLine("Changes Updated"); Console.ReadKey(); }
public string ImportCustomer(string patchname) { string result_msage = ""; int count_i = 0; int count_row = 0; string fileName = patchname; FileInfo file = new FileInfo(Path.Combine(rootFolders, fileName)); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet workSheet = package.Workbook.Worksheets["Пользователи"]; workSheet.Cells[1, 1].Value = "Участники"; workSheet.Cells[1, 1].Style.Font.Size = 14; workSheet.Cells[1, 1].Style.Font.Bold = true; workSheet.Cells["A1:J1"].Merge = true; int totalRows = workSheet.Dimension.Rows; List <UserInfo> customerList = new List <UserInfo>(); for (int i = 2; i <= totalRows; i++) { if (workSheet.Cells[i, 1].Value != null && workSheet.Cells[i, 2].Value != null && workSheet.Cells[i, 3].Value != null && workSheet.Cells[i, 4].Value != null && workSheet.Cells[i, 5].Value != null && workSheet.Cells[i, 6].Value != null && workSheet.Cells[i, 7].Value != null && workSheet.Cells[i, 8].Value != null && workSheet.Cells[i, 9].Value != null && workSheet.Cells[i, 10].Value != null) { var distantions_test = _context.UserInfo.Where(p => p.Login == workSheet.Cells[i, 1].Value.ToString()); if (distantions_test.Count() == 0) { string logo = "http://90.189.158.10/folders/nophoto.png"; customerList.Add(new UserInfo { Login = workSheet.Cells[i, 1].Value.ToString(), Password = passwordGenerate.Get_Password_Two_Autentification(workSheet.Cells[i, 2].Value.ToString()), Rol = workSheet.Cells[i, 3].Value.ToString(), Fam = workSheet.Cells[i, 4].Value.ToString(), Name = workSheet.Cells[i, 5].Value.ToString(), Patronimic = workSheet.Cells[i, 6].Value.ToString(), Years = (short)workSheet.Cells[i, 7].Value, Logo = logo, Email = workSheet.Cells[i, 8].Value.ToString(), Isman = (bool)workSheet.Cells[i, 9].Value, IdHelth = (short)workSheet.Cells[i, 10].Value, }); count_i = i - 3; result_msage = "Все строки успешно сохранены, всего" + count_i + " строк"; } } else { result_msage = "Сохранено: " + (count_i) + " строк. " + (count_row - count_i) + " строка не заполнена, проверьте и попробуйте снова"; break; } } _context.UserInfo.AddRange(customerList); _context.SaveChanges(); return(result_msage); } }
public void Create(Categorias categoria) { _context.DbCategorias.Add(categoria); _context.SaveChanges(); }
public ProcessResponse ProcessResponse(string Name, string ContactNumber, string ComponentType, string ComponentName, int Quantity, string IsPriorityRequest) { ProcessResponse pResponse = new ProcessResponse(); ProcessRequest pRequest = new ProcessRequest(); //Random r = new Random(); //pResponse.RequestId = r.Next(10, 200); var DateofDelivery = DateTime.Now; ProcessDetail a = _test.ProcessDetails.FirstOrDefault(c => c.ContactNumber == ContactNumber); if (ComponentType == "Integral" && (IsPriorityRequest == "No" || IsPriorityRequest == null)) { pResponse.RequestId = a.RequestId; using (var client = new HttpClient()) { //pRequest.ComponentType = a.ComponentType; client.BaseAddress = new Uri("https://localhost:44344"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("api/PackageDelivery/GetPackagingDeliveryCharge/" + ComponentType + "," + Quantity).Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; string PandD = JsonConvert.DeserializeObject <string>(responseString); //pResponse.PackagingAndDeliveryCharge = (double?)PandD; pResponse.PackagingAndDeliveryCharge = Convert.ToDouble(PandD); } } pResponse.ProcessingCharge = 500; //pResponse.PackagingAndDeliveryCharge = 300; pResponse.DateofDelivery = DateofDelivery.AddDays(5); a.PackagingAndDeliveryCharge = pResponse.PackagingAndDeliveryCharge; a.ProcessingCharge = pResponse.ProcessingCharge; a.DateofDelivery = DateofDelivery.AddDays(5); _test.SaveChanges(); //return pResponse; } if (ComponentType == "Integral" && IsPriorityRequest == "Yes") { pResponse.RequestId = a.RequestId; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44344"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("api/PackageDelivery/GetPackagingDeliveryCharge/" + ComponentType + "," + Quantity).Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; string PandD = JsonConvert.DeserializeObject <string>(responseString); //pResponse.PackagingAndDeliveryCharge = (double?)PandD; pResponse.PackagingAndDeliveryCharge = Convert.ToDouble(PandD); //_test.SaveChanges(); } } pResponse.ProcessingCharge = 700; //pResponse.PackagingAndDeliveryCharge = 500; pResponse.DateofDelivery = DateofDelivery.AddDays(2); a.PackagingAndDeliveryCharge = pResponse.PackagingAndDeliveryCharge; a.ProcessingCharge = pResponse.ProcessingCharge; a.DateofDelivery = DateofDelivery.AddDays(2); _test.SaveChanges(); //return pResponse; } //if(ComponentType == "Integral") if (ComponentType == "Accessory") { pResponse.RequestId = a.RequestId; using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44344"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("api/PackageDelivery/GetPackagingDeliveryCharge/" + ComponentType + "," + Quantity).Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; string PandD = JsonConvert.DeserializeObject <string>(responseString); //pResponse.PackagingAndDeliveryCharge = (double?)PandD; pResponse.PackagingAndDeliveryCharge = Convert.ToDouble(PandD); //_test.SaveChanges(); } } pResponse.ProcessingCharge = 300; //pResponse.PackagingAndDeliveryCharge = 500; pResponse.DateofDelivery = DateofDelivery.AddDays(5); a.PackagingAndDeliveryCharge = pResponse.PackagingAndDeliveryCharge; a.ProcessingCharge = pResponse.ProcessingCharge; a.DateofDelivery = DateofDelivery.AddDays(2); _test.SaveChanges(); } return(pResponse); }
public void Create(Preguntas pregunta) { _context.DbPreguntas.Add(pregunta); _context.SaveChanges(); }