public JsonResult OtherChargesAction(int id, bool isAddOtherCharges = false, decimal amount = 0, string details = null) { JsonResult json = new JsonResult(); var result = false; var additionalfeeid = 0; if (id > 0 && isAddOtherCharges == true) { try { //add other charges here BookingAdditionalFee bookingAdditionalFee = new BookingAdditionalFee() { BookingId = id, Name = details, Fee = amount, Status = 1 }; additionalfeeid = bookingService.AddOtherCharges(bookingAdditionalFee); if (additionalfeeid > 0) { result = true; } } catch (Exception) { throw; } } if (id > 0 && isAddOtherCharges == false) { try { result = bookingService.UpdateAddionalChargesStatus(id, 0); } catch (Exception) { throw; } } if (result) { json.Data = new { success = true, msg = "success", data = additionalfeeid }; } else { json.Data = new { success = false, Messag = "Unable to Perform Operation in Booking." }; } return(json); }
/// <summary> /// to add entry in booking addothercharges table /// </summary> /// <param name="bookingAdditionalFee"></param> /// <returns></returns> public int AddOtherCharges(BookingAdditionalFee bookingAdditionalFee) { var context = new HMSContext(); context.BookingAdditionalFees.Add(bookingAdditionalFee); var result = context.SaveChanges() > 0; if (result) { return(bookingAdditionalFee.Id); } else { return(0); } }