public void AddPrice(ApiHeader apiHeader, EditPriceModel models) { var url = ApiUrl.Default.RootApi + ApiUrl.Default.AddPrice; //var ob = JsonConvert.SerializeObject(models); Restful.Post(url, apiHeader, models); }
public ActionResult AddPrice(string json) { if (Session["auth_info"] != null) { try { var authInfo = (AuthInfo)Session["auth_info"]; IList <PriceModel> listPrice; listPrice = JsonConvert.DeserializeObject <IList <PriceModel> >(json); //foreach (var item in listPrice) // if (string.IsNullOrEmpty(item.Id)) // listPrice.Remove(item); var model = new EditPriceModel(); model.HospitalId = authInfo.CurrentSelectedClinic.ClinicId; model.Prices = listPrice; _priceService.AddPrice(null, model); TempData[GlobalConstant.ErrorTemp] = "List prices successfully updated."; return(Json(new { success = "true" }, JsonRequestBehavior.AllowGet)); } catch (ApiException ex) { TempData[GlobalConstant.ErrorTemp] = ex.Message; return(Json(new { success = "false" }, JsonRequestBehavior.AllowGet)); } } else { TempData[GlobalConstant.ErrorTemp] = GlobalConstant.SessionExpiredOrNotLogin; return(RedirectToAction("Index", "Home")); } }
public ActionResult DeletePricing(int ID) { IPriceService PricingService = new PriceService(); EditPriceModel WebPrice = PricingService.GetPrice(ID); return(View(WebPrice)); }
public ActionResult EditPricing(EditPriceModel WebPageData) { try { if (ModelState.IsValid) { IPriceService PricingService = new PriceService(); bool updateStatus = PricingService.UpdatePrice(WebPageData); if (updateStatus == true) { return(RedirectToAction("ManagePricings", "Administration")); } else { ModelState.AddModelError("", "Failed to update the record"); } } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionErrorMessage(Ex)); } // If we got this far, something failed, redisplay form return(View(WebPageData)); }
bool IPriceService.UpdatePrice(EditPriceModel WebPageData) { using (var GiftEntity = new GiftEntities()) { int IdToSearchFor = Convert.ToInt32(WebPageData.DatabaseID); Price PriceToUpdate = (from c in GiftEntity.Prices where c.ID == IdToSearchFor select c).FirstOrDefault(); if (PriceToUpdate == null) { throw new Exception("Trying to update a Price that does not exist"); } PriceToUpdate.PricingName = WebPageData.PricingName; PriceToUpdate.CardPrice = Convert.ToDecimal(WebPageData.CardPrice); PriceToUpdate.TransactionPrice = Convert.ToDecimal(WebPageData.TransactionPrice); PriceToUpdate.SupportTransactionPrice = Convert.ToDecimal(WebPageData.SupportTransactionPrice); PriceToUpdate.GiftMonthlyFee = Convert.ToDecimal(WebPageData.GiftMonthlyFee); PriceToUpdate.CardholderMonthlyFee = Convert.ToDecimal(WebPageData.CardholderMonthlyFee); PriceToUpdate.CardHolderPercentageCharge = Convert.ToInt32(WebPageData.CardHolderPercentageCharge); PriceToUpdate.AfterXMonths = Convert.ToInt32(WebPageData.AfterXMonths); //GiftEntity.Prices.ApplyCurrentValues(PriceToUpdate); GiftEntity.SaveChanges(); //SaveOptions.AcceptAllChangesAfterSave return(true); } }
// G e t P r i c e EditPriceModel IPriceService.GetPrice(int ID) { IPriceDAO PriceData = new PriceDAO(); Price DBPrice = PriceData.GetPriceByID(ID); EditPriceModel WebPrice = new EditPriceModel(); WebPrice.DatabaseID = Convert.ToString(DBPrice.ID); WebPrice.PricingName = DBPrice.PricingName; WebPrice.CardPrice = DBPrice.CardPrice.ToString(); WebPrice.TransactionPrice = DBPrice.TransactionPrice.ToString(); WebPrice.SupportTransactionPrice = DBPrice.SupportTransactionPrice.ToString(); WebPrice.GiftMonthlyFee = DBPrice.GiftMonthlyFee.ToString(); WebPrice.CardholderMonthlyFee = DBPrice.CardholderMonthlyFee.ToString(); WebPrice.CardHolderPercentageCharge = DBPrice.CardHolderPercentageCharge.ToString(); WebPrice.AfterXMonths = DBPrice.AfterXMonths.ToString(); return(WebPrice); }
// G e t P r i c e s List <EditPriceModel> IPriceService.GetPrices() { IPriceDAO PriceData = new PriceDAO(); List <Price> DBPrices = PriceData.ListPrices(); List <EditPriceModel> WebPrices = new List <EditPriceModel>(); foreach (Price DBPrice in DBPrices) { EditPriceModel WebPrice = new EditPriceModel(); WebPrice.DatabaseID = Convert.ToString(DBPrice.ID); WebPrice.PricingName = DBPrice.PricingName; WebPrice.CardPrice = DBPrice.CardPrice.ToString(); WebPrice.TransactionPrice = DBPrice.TransactionPrice.ToString(); WebPrice.SupportTransactionPrice = DBPrice.SupportTransactionPrice.ToString(); WebPrice.GiftMonthlyFee = DBPrice.GiftMonthlyFee.ToString(); WebPrice.CardholderMonthlyFee = DBPrice.CardholderMonthlyFee.ToString(); WebPrice.CardHolderPercentageCharge = DBPrice.CardHolderPercentageCharge.ToString(); WebPrice.AfterXMonths = DBPrice.AfterXMonths.ToString(); WebPrices.Add(WebPrice); } return(WebPrices); }