public void ResearchDoctrine(Doctrine doctrine) { Debug.Log("ResearchDoctrine called"); learnedDoctrine[doctrine] = true; CheckLearnableDoctrine(); Engine.instance.UpdateXp(-doctrine.GetDoctrineCost()); }
/// <summary> /// Returns a doctrine for a given account and doctrine id. /// </summary> /// <param name="accountId">The currently logged-in account id for security checking.</param> /// <param name="doctrineId">The id for which a doctrine object should be returned.</param> /// <returns>A doctrine object.</returns> internal Doctrine GetDoctrineDetail(int accountId, int doctrineId) { Doctrine doctrine = this.doctrineShipsRepository.GetDoctrine(doctrineId); if (doctrine != null) { if (accountId == doctrine.AccountId) { return(doctrine); } } return(null); }
static void Main() { const int AMMOUNT = 50; Doctrine myDoctrine = new Doctrine(); string[] scriptures = new string[AMMOUNT]; scriptures[0] = new Doctrine("hello"); do { for (int i = 0; i< AMMOUNT; i++) { Console.WriteLine() } Console.ReadLine(); } }
public ActionResult UpdateDoctrine(AccountDoctrinesViewModel viewModel) { // Convert the currently logged-in account id to an integer. int accountId = Conversion.StringToInt32(User.Identity.Name); if (ModelState.IsValid) { // Create an Auto Mapper map between the doctrine entity and the view model. Mapper.CreateMap <AccountDoctrinesViewModel, Doctrine>(); // Sanitise the form values. viewModel.AccountId = accountId; viewModel.Name = Conversion.StringToSafeString(viewModel.Name); viewModel.Description = viewModel.Description; viewModel.ImageUrl = Server.HtmlEncode(viewModel.ImageUrl) ?? string.Empty; // Populate a doctrine with automapper and pass it back to the service layer for update. Doctrine doctrine = Mapper.Map <AccountDoctrinesViewModel, Doctrine>(viewModel); IValidationResult validationResult = this.doctrineShipsServices.UpdateDoctrine(doctrine); // If the validationResult is not valid, something did not validate in the service layer. if (validationResult.IsValid) { TempData["Status"] = "The doctrine was successfully updated."; } else { TempData["Status"] = "Error: The doctrine was not updated, a validation error occured.<br /><b>Error Details: </b>"; foreach (var error in validationResult.Errors) { TempData["Status"] += error.Value + "<br />"; } } return(RedirectToAction("Doctrines")); } else { // Re-populate the view model and return with any validation errors. viewModel.Doctrines = this.doctrineShipsServices.GetDoctrineList(accountId); ViewBag.Status = "Error: The doctrine was not updated, a validation error occured."; return(View("~/Views/Account/Doctrines.cshtml", viewModel)); } }
internal IValidationResult Doctrine(Doctrine doctrine) { IValidationResult validationResult = new ValidationResult(); // Check that the doctrine has a valid account id. if (doctrine.AccountId < 0 || doctrine.AccountId > int.MaxValue) { validationResult.AddError("AccountId.Range", "AccountId can not be less than or equal to 0. Also, the upper limit cannot exceed the max value of the int data type."); } // Null & empty checks. if (doctrine.Name == null || doctrine.Name == string.Empty) { validationResult.AddError("Name.Null", "Name cannot be null or empty."); } if (doctrine.Description == null) { validationResult.AddError("Description.Null", "Description cannot be null."); } if (doctrine.ImageUrl == null) { validationResult.AddError("ImageUrl.Null", "ImageUrl cannot be null."); } if (doctrine.LastUpdate == null) { validationResult.AddError("LastUpdate.Null", "LastUpdate cannot be null."); } // Is this a https url? if (doctrine.ImageUrl != string.Empty && doctrine.ImageUrl.Length >= 5) { if (doctrine.ImageUrl.Substring(0, 5) != "https") { validationResult.AddError("ImageUrl.Https", "ImageUrl must start with https. Please use an image hosting service such as imgur that supports https."); } } return(validationResult); }
/// <summary> /// <para>Adds a Doctrine.</para> /// </summary> /// <param name="doctrine">A populated doctrine object.</param> /// <returns>Returns a validation result object.</returns> internal IValidationResult AddDoctrine(Doctrine doctrine) { IValidationResult validationResult = new ValidationResult(); doctrine.LastUpdate = DateTime.UtcNow; // Validate the new doctrine. validationResult = this.doctrineShipsValidation.Doctrine(doctrine); if (validationResult.IsValid == true) { // Add the new doctrine. this.doctrineShipsRepository.CreateDoctrine(doctrine); this.doctrineShipsRepository.Save(); // Log the addition. logger.LogMessage("Doctrine '" + doctrine.Name + "' Successfully Added.", 2, "Message", MethodBase.GetCurrentMethod().Name); } return(validationResult); }
/// <summary> /// Deletes a doctrine. /// </summary> /// <param name="accountId">The account Id of the requestor. The account Id should own the doctrine being deleted.</param> /// <param name="doctrineId">The doctrine Id to be deleted.</param> /// <returns>Returns true if the deletion was successful or false if not.</returns> internal bool DeleteDoctrine(int accountId, int doctrineId) { Doctrine doctrine = this.doctrineShipsRepository.GetDoctrine(doctrineId); if (doctrine != null) { // If the account Id matches the account Id of the doctrine being deleted, continue. if (accountId == doctrine.AccountId) { // Delete all of the doctrine ship fits. this.doctrineShipsRepository.DeleteDoctrineShipFitsByDoctrineId(doctrine.DoctrineId); // Delete the doctrine and log the event. this.doctrineShipsRepository.DeleteDoctrine(doctrine.DoctrineId); this.doctrineShipsRepository.Save(); logger.LogMessage("Doctrine '" + doctrine.Name + "' Successfully Deleted For Account Id: " + doctrine.AccountId, 1, "Message", MethodBase.GetCurrentMethod().Name); return(true); } } return(false); }
/// <summary> /// Updates a doctrine for a particular account. /// </summary> /// <param name="doctrine">A partially populated doctrine object to be updated.</param> /// <returns>Returns a validation result object.</returns> internal IValidationResult UpdateDoctrine(Doctrine doctrine) { IValidationResult validationResult = new ValidationResult(); var existingDoctrine = this.doctrineShipsRepository.GetDoctrine(doctrine.DoctrineId); if (existingDoctrine != null) { if (existingDoctrine.AccountId != doctrine.AccountId) { validationResult.AddError("Doctrine.Permission", "The doctrine being modified does not belong to the requesting account."); } else { // Map the updates to the existing doctrine. existingDoctrine.Name = doctrine.Name; existingDoctrine.Description = doctrine.Description; existingDoctrine.ImageUrl = doctrine.ImageUrl; existingDoctrine.IsOfficial = doctrine.IsOfficial; existingDoctrine.IsDormant = doctrine.IsDormant; existingDoctrine.LastUpdate = DateTime.UtcNow; // Validate the doctrine updates. validationResult = this.doctrineShipsValidation.Doctrine(existingDoctrine); if (validationResult.IsValid == true) { // Update the existing record, save and log. this.doctrineShipsRepository.UpdateDoctrine(existingDoctrine); this.doctrineShipsRepository.Save(); logger.LogMessage("Doctrine '" + existingDoctrine.Name + "' Successfully Updated For Account Id: " + existingDoctrine.AccountId, 2, "Message", MethodBase.GetCurrentMethod().Name); } } } return(validationResult); }
public void UpdateDoctrine(Doctrine doctrine) { DoctrineOperations.UpdateDoctrine(doctrine); }
/// <summary> /// Updates a doctrine for a particular account. /// </summary> /// <param name="doctrine">A partially populated doctrine object to be updated.</param> /// <returns>Returns a validation result object.</returns> public IValidationResult UpdateDoctrine(Doctrine doctrine) { return(ShipFitManager.UpdateDoctrine(doctrine)); }
/// <summary> /// <para>Adds a Doctrine.</para> /// </summary> /// <param name="doctrine">A populated doctrine object.</param> /// <returns>Returns a validation result object.</returns> public IValidationResult AddDoctrine(Doctrine doctrine) { return(ShipFitManager.AddDoctrine(doctrine)); }
public IValidationResult Doctrine(Doctrine doctrine) { return(ShipFitCheck.Doctrine(doctrine)); }
internal Doctrine CreateDoctrine(Doctrine doctrine) { doctrine.ObjectState = ObjectState.Added; this.unitOfWork.Repository <Doctrine>().Insert(doctrine); return(doctrine); }
internal Doctrine AddDoctrine(Doctrine doctrine) { this.unitOfWork.Repository <Doctrine>().Insert(doctrine); return(doctrine); }
internal void UpdateDoctrine(Doctrine doctrine) { doctrine.ObjectState = ObjectState.Modified; this.unitOfWork.Repository <Doctrine>().Update(doctrine); }
public Doctrine AddDoctrine(Doctrine doctrine) { return(DoctrineOperations.AddDoctrine(doctrine)); }
public Doctrine CreateDoctrine(Doctrine doctrine) { return(DoctrineOperations.CreateDoctrine(doctrine)); }