public IActionResult Put(int id, [FromBody] FractionCalculationModel value)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         value.FractionCalculationId = id;
         _FractionCalculationService.UpdateFractionCalculation(value);
         responseData.Results = _FractionCalculationService.GetFractionCalculation(id);
         responseData.Status  = "OK";
     }
     catch (Exception ex)
     {
         responseData.Status       = "Failed";
         responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
     }
     return(Ok(responseData));
 }
        public int AddFractionCalculation(FractionCalculationModel[] model)
        {
            Dictionary <double, int> doctorParent = new Dictionary <double, int>();

            foreach (var fraction in model)
            {
                FractionCalculationModel frac = new FractionCalculationModel();
                frac = fraction;
                double ParentId   = fraction.IsParentId;
                bool   is_integer = (ParentId % 1) == 0;

                doctorParent.Add(frac.ParentId, frac.DoctorId);

                if (fraction.IsParentId != 0)
                {
                    frac.IsParentId = doctorParent[Convert.ToInt32(ParentId)];
                }
                db.FractionCalculation.Add(frac);
                db.SaveChanges();
            }
            return(model[0].BillTxnItemId);
        }
 public FractionCalculationModel UpdateFractionCalculation(FractionCalculationModel model)
 {
     db.Entry(model).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return(model);
 }