public async Task <IActionResult> CalculateAsync([FromBody] SavijanjePravougaonogPresekaEC2Model model) { if (!ModelState.IsValid) { var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(BadRequest( new { message = "Invalid model", error = allErrors.Select(v => v.ErrorMessage), modelExp = new { b = 25, h = 40, d1 = 6, d2 = 4, armtype = "B500B", betonClass = "C25/30", mg = 50, mq = 30, msd = 0, ng = 50, nq = 0, nsd = 0, mu = 0 } })); } try { if (model == null) { throw new ArgumentException("Pogresno uneti podaci!"); } var Result = new SavijanjePravougaonogPresekaEC2Model(); await Task.Run(() => { Result = sav.Calculate(model); }); return(Ok(Result)); } catch (Exception e) { return(BadRequest(new { error = e.Message })); } }
public async Task <IActionResult> CalculateAsync([FromBody] SavijanjePravougaonogPresekaEC2Model model) { try { if (model == null) { throw new ArgumentException("Pogresno uneti podaci!"); } var Result = new SavijanjePravougaonogPresekaEC2Model(); await Task.Run(() => { Result = sav.Calculate(model); }); return(Ok(Result)); } catch (Exception e) { return(BadRequest(new { error = e.Message })); } }
public SavijanjePravougaonogPresekaEC2Model Calculate(SavijanjePravougaonogPresekaEC2Model input) { SavijanjePravougaonogPresekaEC2Model result = input; if (input.Msd == 0) { using (CalculatorEC2Logic.SavijanjePravougaonogPresekaEC2 sav = new CalculatorEC2Logic.SavijanjePravougaonogPresekaEC2( b: input.b, h: input.h, d1: input.d1, d2: input.d2, beton: TabeleEC2.BetonClasses.GetBetonClassListEC().Single(b => b.name == input.betonClass), armatura: TabeleEC2.ReinforcementType.GetArmatura().Single(a => a.name == input.armtype), Mg: input.Mg, Mq: input.Mq, Ng: input.Ng, Nq: input.Nq, kof: input.h == 0 ? TabeleEC2.KofZaProracunPravougaonogPresekaEC.GetItem_Full(input.mu) : null)) { ///Doo some thing result.result = new SavijanjePravougaonogPresekaEC2Model.ResultModel() { kof = sav.KofZaProracunPravougaonogPreseka, As1_pot = sav.As1_pot, As2_pot = sav.As2_pot, Msd = sav.Msd, Msds = sav.Msds, Nsd = sav.Nsd, μSd = sav.μSd, Result = sav.ToString(), }; result.h = input.h == 0 ? sav.h : result.h; } } else { using (CalculatorEC2Logic.SavijanjePravougaonogPresekaEC2 sav = new CalculatorEC2Logic.SavijanjePravougaonogPresekaEC2( b: input.b, h: input.h, d1: input.d1, d2: input.d2, beton: TabeleEC2.BetonClasses.GetBetonClassListEC().Single(b => b.name == input.betonClass), armatura: TabeleEC2.ReinforcementType.GetArmatura().Single(a => a.name == input.armtype), Msd: input.Msd, Nsd: input.Nsd, kof: input.h == 0 ? TabeleEC2.KofZaProracunPravougaonogPresekaEC.GetItem_Full(input.mu) : null)) { ///Doo some thing result.result = new SavijanjePravougaonogPresekaEC2Model.ResultModel() { kof = sav.KofZaProracunPravougaonogPreseka, As1_pot = sav.As1_pot, As2_pot = sav.As2_pot, Msd = sav.Msd, Msds = sav.Msds, Nsd = sav.Nsd, μSd = sav.μSd, Result = sav.ToString(), }; result.h = input.h == 0 ? sav.h : result.h; } } return(result); }
public SavijanjePravougaonogPresekaEC2Model Calculate(SavijanjePravougaonogPresekaEC2Model input) { IBetonModel beton; IReinforcementTypeModel armatura; SavijanjePravougaonogPresekaEC2Model result = input; if (input.settings != null) { beton = new BetonModelEC(input.betonClass, input.settings.alfa_cc, input.settings.alfa_ct, input.settings.y_c); armatura = ReinforcementType.GetArmatura(input.settings.y_s).Single(a => a.name == input.armtype); } else { beton = new BetonModelEC(input.betonClass); armatura = ReinforcementType.GetArmatura().Single(a => a.name == input.armtype); } if (beton == null) { throw new System.ArgumentNullException(nameof(beton), "cant be null"); } if (armatura == null) { throw new System.ArgumentNullException(nameof(armatura), "cant be null"); } var geometry = new ElementGeometry() { b = input.b, h = input.h, d1 = input.d1, d2 = input.d2 }; var cs = new CoeffService(new Material { armatura = armatura, beton = beton }, geometry); using (CalculatorEC2Logic.BendingRectangularCrossSectionEC2 sav = new CalculatorEC2Logic.BendingRectangularCrossSectionEC2( material: new Material() { beton = beton, armatura = armatura }, geometry: geometry, forces: input.Msd == 0 ? new CalculatorEC2Logic.ForcesBendingAndCompressison(1.35 * input.Mg + 1.5 * input.Mq, 1.35 * input.Ng + 1.5 * input.Nq) : new CalculatorEC2Logic.ForcesBendingAndCompressison(input.Msd, input.Nsd), kof: input.h == 0 ? cs.GetByμ(input.mu) : null)) { ///Doo some thing result.result = new SavijanjePravougaonogPresekaEC2Model.ResultModel() { coef = sav.KofZaProracunPravougaonogPreseka, As1_req = sav.As1_pot, As2_req = sav.As2_pot, Msd = sav.Forces.Msd, Msds = sav.Forces.Msds(sav.Geometry.h, sav.Geometry.d1), Nsd = sav.Forces.Nsd, μSd = sav.KofZaProracunPravougaonogPreseka.μRd, Result = sav.ToString(), }; result.h = input.h == 0 ? sav.Geometry.h : result.h; } return(result); }