public void UpdateCurrentDefinitivePlans(UpdateSuggestedPlanModel updatePlan) { var defPlansList = _curretDefinitvePlans; var ofertPlan = _ofertPlanList.Where(x => x.Plan.Equals(updatePlan.Plan)).FirstOrDefault(); _curretDefinitvePlans = defPlansList.Select(x => new DefinitivePlanModel { RecomendadorId = x.RecomendadorId, Plan = x.Plan, Bono = x.Bono, Roaming = x.Roaming, TMM_s_iva = x.TMM_s_iva, TmmString = TelefonicaHelper.FormatCultureNumber(x.TMM_s_iva) }).ToList(); // foreach (var plan in _curretDefinitvePlans) { if (plan.RecomendadorId == updatePlan.PlanToEdit) { plan.Plan = ofertPlan.Plan; plan.Bono = ofertPlan.Bono_ / 1024; plan.Roaming = ofertPlan.Roaming; plan.TMM_s_iva = ofertPlan.TMM_s_iva; plan.TmmString = TelefonicaHelper.FormatCultureNumber(ofertPlan.TMM_s_iva); } } }
public async Task <JsonResult> UpdateDefinitivePlan([FromBody] UpdateSuggestedPlanModel updatePlan) { try { _telefonicaApi.UpdateCurrentDefinitivePlans(updatePlan); var defPlansList = _telefonicaApi.GetCurrentDefinitivePlans(); return(new JsonResult(defPlansList)); }catch (Exception ex) { var extraData = new { step = "ex", from = "UI" }; var log = new Log() { Reference = "UpdateDefinitivePlan", Messsage = ex.Message, ExtraData = extraData }; await _telefonicaApi.InsertLog(log); var data = new { status = "error", message = "Error al actualizar plan definitivo" }; return(Json(data)); } }