public async Task AddOrEditPricePerPeriod(GymPrices gymPrices) { var gymPrice = await _context.GymPrices.FirstOrDefaultAsync(gp => gp.GymId == gymPrices.GymId && gp.Subscribtion_Type == gymPrices.Subscribtion_Type); if (gymPrice == null) { _context.GymPrices.Add(gymPrices); } else { gymPrice.Subscribtion_Price = gymPrices.Subscribtion_Price; gymPrice.Subscribtion_Type = gymPrices.Subscribtion_Type; gymPrice.GymId = gymPrices.GymId; _context.Entry(gymPrice).State = EntityState.Modified; } await this.Commit(); }
public ActionResult EditPricePerPeriod(GymPrices gymPrice) { var IsEntered = _gymPriceRepository.AddOrEditPricePerPeriod(gymPrice); return(Ok(new JsonResult(IsEntered))); }