public ProcessRequestDTO SaveData(ProcessRequestDTO model) { log.MethodStart(); ProcessRequestDTO objReturn = new ProcessRequestDTO(); using (var trans = _db.Database.BeginTransaction()) { try { var objModel = _db.TRProcessRequests.FirstOrDefault(x => x.pcr_code == model.pcr_code); objModel = _mapper.Map <TRProcessRequest>(model); //objModel.hos_status = objModel.hos_active == true ? "A" : "I"; _db.SaveChanges(); trans.Commit(); } catch (Exception ex) { // TODO: Handle failure trans.Rollback(); } finally { trans.Dispose(); } } log.MethodFinish(); return(objReturn); }
/*public ActionResult ComponentProcessing(Component component) * { * string Results; * HttpClient client = new HttpClient(); * Uri baseAddress = new Uri("http://localhost:2939/"); * client.BaseAddress = baseAddress; * * JArray paramList = new JArray(); * Component components = new Component { * Name = component.Name, * ContactNumber = component.ContactNumber, * CreditCardNumber = component.CreditCardNumber, * ComponentType = component.ComponentType, * ComponentName = component.ComponentName, * Quantity = component.Quantity, * IsPriorityRequest = component.IsPriorityRequest * }; * * * paramList.Add(JsonConvert.SerializeObject(components)); * * * HttpResponseMessage response = client.PostAsJsonAsync("api/ComponentProcessingMicroservice/", paramList).Result; * if (response.IsSuccessStatusCode) * { * Results = response.Content.ReadAsStringAsync().Result; * } * else * { * Results = null; * } * List<string> Response = JsonConvert.DeserializeObject<List<string>>(Results); * return View("ProcessResponse"); * }*/ /* public async Task<ActionResult> Confirmation() * { * _log4net.Info("Payment Confirmation initiated"); * string confirm = "true"; * dynamic details = ""; * var abc = JsonConvert.SerializeObject(confirm); * var data = new StringContent(abc, Encoding.UTF8, "application/json"); * * using (var client = new HttpClient()) * { * * HttpResponseMessage response = await client.GetAsync(string.Format("https://localhost:44346/api/ComponentProcessingMicroservice/True?message={0}", confirm)); * // var response = await client.PostAsync("https://localhost:44346/api/ComponentProcessingMicroservice", data); * * string name = response.Content.ReadAsStringAsync().Result; * * * } * string x = (string)details; * if (x == "Success") * return View("Confirmation"); * else * return View("Failed"); * * }*/ public async Task <ActionResult> Confirmation() { _log4net.Info("Payment Confirmation initiated"); Submission res = new Submission() { Result = "True" }; string name = ""; //string confirm = "true"; dynamic details = ""; var abc = JsonConvert.SerializeObject(res); var data = new StringContent(abc, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.PostAsync("https://localhost:44392/api/ComponentProcessingMicroservice", data); name = response.Content.ReadAsStringAsync().Result; } string x = (string)name; if (x == "Success") { db.ProcessDb.Add(Response); db.SaveChanges(); return(View("Confirmation")); } else { return(View("Failed")); } }
public IActionResult Update(long id, [FromBody] Process item) { if (item == null || item.ID != id) { return(BadRequest()); } var process = _context.Process.FirstOrDefault(t => t.ID == id); if (process == null) { return(NotFound()); } process.WindowName = item.WindowName; _context.Process.Update(process); _context.SaveChanges(); return(new NoContentResult()); }
//User will confirm if he wants to Confirm the payment or not public async Task <ActionResult> Confirmation() { try { _log4net.Info("Payment Confirmation initiated"); Submission res = new Submission() { Result = "True" }; string name = ""; dynamic details = ""; var abc = JsonConvert.SerializeObject(res); var data = new StringContent(abc, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { _log4net.Info("Confirmation sent to Component Microservice For Payment"); // var response = await client.PostAsync("https://localhost:44392/api/ComponentProcessingMicroservice", data); var response = await client.PostAsync(_config["Links:ComponentMicroService"] + "/ComponentProcessingMicroservice", data); _log4net.Info("Component Microservice uri invoked http://52.154.250.90/api"); name = response.Content.ReadAsStringAsync().Result; } _log4net.Info("Success or failed Message received from Component Moicroservice"); string x = (string)name; if (x == "Success") { _log4net.Info("Respose added to db "); db.ProcessDb.Add(Response); db.SaveChanges(); return(View("Confirmation", Response)); } else { return(View("Failed")); } } catch (Exception ex) { _log4net.Info("Exception In Confirmation ActionResult"); return(View("Error1", ex)); } }
public ProcessRequestDTO SaveData(ProcessRequestDTO model) { log.MethodStart(); var currentDateTime = DateTime.Now; var currentUser = ""; var new_pcr_code = ""; ProcessRequestDTO objReturn = new ProcessRequestDTO(); using (var trans = _db.Database.BeginTransaction()) { try { var objModel = new TRProcessRequest(); objModel = _mapper.Map <TRProcessRequest>(model); var currentYearCode = $"PCR_{DateTime.Now.ToString("yyyyMMdd")}"; var objDataList = _db.TRProcessRequests.Where(x => x.pcr_code.Contains(currentYearCode)).ToList(); if (objDataList.Count > 0) { var lastData = objDataList.LastOrDefault(); var lastCode = lastData.pcr_code.Replace(currentYearCode, ""); var newCodeInt = (Convert.ToInt32(lastCode) + 1); new_pcr_code = currentYearCode + newCodeInt.ToString("0000"); } else { new_pcr_code = currentYearCode + (1).ToString("0000"); } objModel.pcr_id = 0; objModel.pcr_code = new_pcr_code; objModel.pcr_status = "W"; objModel.pcr_active = true; objModel.pcr_status = objModel.pcr_active == true ? "A" : "I"; objModel.pcr_createdate = currentDateTime; objModel.pcr_updatedate = currentDateTime; currentUser = objModel.pcr_updateuser; _db.TRProcessRequests.Add(objModel); var objData = _db.TRProcessRequests.FirstOrDefault(x => x.pcr_code == model.pcr_prev_code); if (objData != null) { objData.pcr_status = "I"; objData.pcr_active = false; objData.pcr_updateuser = model.pcr_updateuser; objData.pcr_updatedate = currentDateTime; } #region Save Log Process ... _db.LogProcesss.Add(new LogProcess() { log_usr_id = currentUser, log_mnu_id = "", log_mnu_name = "ProcessRequest", log_tran_id = objModel.pcr_id.ToString(), log_action = (model.pcr_status == "N" ? "New" : "Update"), log_desc = "Update ProcessRequest " + objModel.pcr_code, log_createuser = currentUser, log_createdate = currentDateTime }); #endregion _db.SaveChanges(); trans.Commit(); objReturn = _mapper.Map <ProcessRequestDTO>(objModel); } catch (Exception ex) { // TODO: Handle failure trans.Rollback(); } finally { trans.Dispose(); } } log.MethodFinish(); return(objReturn); }