public ActionResult AddNewRental(string movie, string customerN) { if (!ValidValue(customerN) && !ValidValue(movie)) { var ErrorMassage = new { ajaxactoin = false, message = "Please enter the name of the Customer and select movie" }; return(Json(ErrorMassage)); } else if (!ValidValue(customerN)) { var ErrorCustomerMassage = new { ajaxactoin = false, message = "Please enter the name of the Customer" }; return(Json(ErrorCustomerMassage)); } else if (!ValidValue(movie)) { var ErrorMovieMassage = new { ajaxactoin = false, message = "please select movie" }; return(Json(ErrorMovieMassage)); } Customer customer = CustomerHelper.GetCustomers().Where(x => x.Name == customerN).FirstOrDefault(); Movie Movie = MovieHelper.GetMovieList().Where(x => x.Name == movie).FirstOrDefault(); bool RentalSuccess = RentalHelper.AddRentals(customer, Movie); if (RentalSuccess) { var RentalIsSuccess = new { ajaxactoin = true, message = "The rent was made" }; return(Json(RentalIsSuccess)); } else { var Rentalfailed = new { ajaxactoin = false, message = "The rent failed" }; return(Json(Rentalfailed)); } }
public ActionResult Delete(string name, string movie) { ViewBag.ErrorMsg = ""; ViewBag.success = ""; bool ExistInFile = RentalHelper.GetRentalList().Exists(x => (x.NameOfcustomer == name && x.NameOfMovie == movie)); if (ExistInFile) { RentalHelper.DeleteRentedMovie(name, movie); if (RentalHelper.DoesMovieReturned(name, movie)) { ViewBag.success = "Movie returned successful!"; } else { ViewBag.ErrorMsg = "There seems to be a problem, Failed to return movie, try again"; } } else { ViewBag.ErrorMsg = "Oops... The customer didn't rent this movie!"; } return(View("ReturnMovie")); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household rentalOwner = null; if (Lot.ResidentialLotSubType == ResidentialLotSubType.kEP10_PrivateLot) { foreach (Household house in Household.GetHouseholdsLivingInWorld()) { if (house.RealEstateManager == null) { continue; } PropertyData data = house.RealEstateManager.FindProperty(Lot); if (data == null) { continue; } if (data.PropertyType == RealEstatePropertyType.PrivateLot) { continue; } rentalOwner = house; break; } } else if (!RentalHelper.IsRentable(Money, Lot)) { rentalOwner = Money.GetDeedOwner(Lot); } if (rentalOwner == null) { return(false); } SimDescription headOfFamily = SimTypes.HeadOfFamily(rentalOwner); if ((headOfFamily != null) && (headOfFamily.CreatedSim != null)) { RentalHelper.SellRentalLot(Money, headOfFamily.CreatedSim, Lot); IncStat("Sold"); } return(true); }
// Externalized to Mover public static bool PresetRentalLotHome(Lot lot, Household house) { try { if (StoryProgression.Main != null) { RentalHelper.SetLotHome(lot, house); } } catch (Exception e) { Common.Exception(lot, e); } return(true); }
public override void OnCallFinished() { try { if (mChosenLot != null) { RentalHelper.SellRentalLot(StoryProgression.Main.Money, Actor, mChosenLot); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } }
public ContractResponse BuildContract(IList <RentalRequest> requests) { var rentalHelper = new RentalHelper(); rentalHelper.ValidateRentalRequests(requests); int requestCount = 0; var response = new ContractResponse { CreatedAt = DateTime.Now }; var details = new List <DetailResponse>(); foreach (var request in requests) { var detail = detailStrategy[request.RentalType](request); response.Total += detail.RentalCost; details.Add(detail); if (!response.HasFamilyDiscount) { requestCount++; if (requestCount >= 3 && requestCount <= 5) { response.HasFamilyDiscount = true; requestCount = 0; } } } response.Details = details; if (response.HasFamilyDiscount) { var rentalDiscount = response.Total * 0.30m; response.Discount = rentalDiscount; response.Total -= rentalDiscount; } return(response); }
public override Phone.Call.ConversationBehavior OnCallConnected() { try { List <Lot> purchaseableLots = RentalHelper.GetPurchaseableLots(); if (purchaseableLots.Count != 0x0) { mChosenLot = RealEstateManager.ChooseLot(purchaseableLots, Actor, Localization.LocalizeString("Gameplay/Locations/LocationHomeDeed:PurchaseLot", new object[0x0]), true); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } return(Phone.Call.ConversationBehavior.JustHangUp); }
protected override bool PrivateUpdate(ScenarioFrame frame) { int totalFunds = Sim.FamilyFunds - MinimumWealth; AddStat("Total Funds", totalFunds); List <Lot> lots = new List <Lot>(); foreach (Lot lot in RentalHelper.GetPurchaseableLots(Manager, Sim.Household)) { if (lot.Household == null) { IncStat("Empty"); continue; } if (totalFunds < RentalHelper.GetPurchaseLotCost(lot)) { IncStat("Too Expensive"); continue; } lots.Add(lot); } AddStat("Choices", lots.Count); if (lots.Count == 0) { IncStat("No Choices"); return(false); } mLot = RandomUtil.GetRandomObjectFromList(lots); RentalHelper.PurchaseRentalLot(Money, Sim.CreatedSim, mLot); return(true); }
public ActionResult CreateNewRentals(string name, string movie) { bool boolean = true; if (RentalHelper.CountingMovieDuplicates(name, movie) <= MovieHelper.CountingMovieDuplicates(name, movie)) { RentalHelper.WriteNewRental(name, movie); if (RentalHelper.DoesMovieReturned(name, movie)) { ErrorMsg = "There seems to be a problem, the movie rental has not been made, try again"; boolean = true; } else { ErrorMsg = "Movie rental successful!"; boolean = false; } } var ReqOfRent = new { strMsg = ErrorMsg, Isbool = boolean }; return(Json(ReqOfRent)); }
// GET: Rental public ActionResult Index() { List <Movie> Movies = RentalHelper.MoviesNotRented(); return(View(Movies)); }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); #region | SERVICE | IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); #region | Validate Request | //Target yoksa veya Entity tipinde değilse, devam etme. if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity)) { return; } #endregion IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(Globals.AdministratorId); #region |DEFINE IMAGE IF EXISTS| Entity preImage = null; if (context.PreEntityImages.Contains("PreImage") && context.PreEntityImages["PreImage"] is Entity) { preImage = (Entity)context.PreEntityImages["PreImage"]; } #endregion #endregion Entity entity = (Entity)context.InputParameters["Target"]; try { if (entity.Attributes.Contains("new_issendingapproval")) { if (entity.GetAttributeValue <bool>("new_issendingapproval")) { EntityReference currency = preImage.Attributes.Contains("transactioncurrencyid") && preImage["transactioncurrencyid"] != null ? (EntityReference)preImage["transactioncurrencyid"] : null; EntityReference projectId = preImage.Attributes.Contains("new_projectid") && preImage["new_projectid"] != null ? (EntityReference)preImage["new_projectid"] : null; MsCrmResultObject productResult = RentalHelper.GetRentalProducts(entity.Id, sda); if (productResult.Success) { //Ürün alındı Product product = ((List <Product>)productResult.ReturnObject)[0]; //Rule alındı RentalControlSetting control = ProductHelper.GetRentalControlSettingByProject(product.Project.Id, sda); //Kiralama tutarı alındı decimal rentalAmount = preImage.GetAttributeValue <Money>("new_rentalfee").Value; if (control.RentalControlSettingId != Guid.Empty) { if (control.ConsultantRate != null) { if (control.ConsultantRate != decimal.MaxValue) { decimal rate = (product.PaymentOfHire.Value * (control.ConsultantRate.Value / 100)); decimal minRate = product.PaymentOfHire.Value - rate; decimal maxRate = product.PaymentOfHire.Value + rate; if (rentalAmount >= minRate && rentalAmount <= maxRate) { //Opsiyona takılmaz. Entity ent = new Entity("product"); ent.Id = product.ProductId; ent["new_usedrentalandsalesstatus"] = new OptionSetValue(4); //Kiralandı. service.Update(ent); entity["statuscode"] = new OptionSetValue((int)RentalStatuses.Tamamlandi); //Kiralama Durumu } else { //Ürün kiralama opsiyonlu //Onaya gönder Entity ent = new Entity("product"); ent.Id = product.ProductId; ent["new_usedrentalandsalesstatus"] = new OptionSetValue(3); //konut durumu kiralama opsiyonlu service.Update(ent); entity["statuscode"] = new OptionSetValue((int)RentalStatuses.OnayBekleniyor); //Kiralama Durumu MsCrmResult mailResult = RentalHelper.SendMailRentalToApproval(product, preImage, UserTypes.IkinciElSatisDirektoru, sda, service); if (!mailResult.Success) { throw new Exception(mailResult.Result); } } } } } } } } } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message + ex.StackTrace); } finally { if (sda != null) { sda.closeConnection(); } } }