private async void SaveHeritage(IRpcEvent e, Guid characterId, Heritage heritage) { using (var context = new StorageContext()) using (var transaction = context.Database.BeginTransaction()) { try { var save = context.Characters.Include(c => c.Heritage).Single(c => c.Id == characterId); heritage.Id = save.HeritageId; context.Entry(save.Heritage).CurrentValues.SetValues(heritage); await context.SaveChangesAsync(); transaction.Commit(); } catch (Exception ex) { this.Logger.Error(ex, "Character Heritage Save"); transaction.Rollback(); } } }
public async Task <IActionResult> Edit(int id, [Bind("HeritageID,description,DateDeces,DateHeritage,EcoleID,montant,BiensID")] Heritage heritage) { if (id != heritage.HeritageID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(heritage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HeritageExists(heritage.HeritageID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BiensID"] = new SelectList(_context.Biens, "BiensID", "BiensID", heritage.BiensID); ViewData["EcoleID"] = new SelectList(_context.Ecole, "EcoleID", "EcoleID", heritage.EcoleID); return(View(heritage)); }
public ActionResult DeleteConfirmed(int id) { Heritage heritage = db.Heritage.Find(id); db.Heritage.Remove(heritage); db.SaveChanges(); return(RedirectToAction("Index")); }
private async Task ExecuteDisplayHeritageCommand(Heritage heritage) { var navigationParams = new NavigationParameters { { "heritage", heritage } }; await NavigationService.NavigateAsync("DisplayHeritage", navigationParams); }
private async Task <bool> Verification(Heritage heritage) { try { Load = true; Body = false; LoadMessage = "Verificando patrimônio"; heritage.SerializeCode = false; heritage.State = true; bool up = await HeritageAPIService.PutAsync(heritage); if (up) { Xamarin.Forms.DependencyService.Get <IMessage>().LongAlert("Patrimônio verificado com sucesso"); Load = false; Body = true; return(true); } else { DialogParameters param = new DialogParameters { { "Message", "Erro ao atualizar patrimônio" }, { "Title", "Erro" }, { "Icon", IconTheme.IconName("bug") } }; DialogService.ShowDialog("DialogPage", param, CloseDialogCallback); Load = false; Body = true; return(false); } } catch (Exception) { Body = true; DialogParameters param = new DialogParameters { { "Message", "Erro ao atualizar patrimônio" }, { "Title", "Erro" }, { "Icon", IconTheme.IconName("bug") } }; DialogService.ShowDialog("DialogPage", param, CloseDialogCallback); Load = false; Body = true; return(false); } }
public ActionResult Edit([Bind(Include = "HeritageID,Description,DateDece,DateHeritage,EcoleID,Montant")] Heritage heritage) { if (ModelState.IsValid) { db.Entry(heritage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EcoleID = new SelectList(db.Ecole, "EcoleID", "Nom", heritage.EcoleID); return(View(heritage)); }
public async Task <IActionResult> Create([Bind("HeritageID,description,DateDeces,DateHeritage,EcoleID,montant,BiensID")] Heritage heritage) { if (ModelState.IsValid) { _context.Add(heritage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BiensID"] = new SelectList(_context.Biens, "BiensID", "BiensID", heritage.BiensID); ViewData["EcoleID"] = new SelectList(_context.Ecole, "EcoleID", "EcoleID", heritage.EcoleID); return(View(heritage)); }
public ICommandResult Handle(CreateHeritageCommand command) { var heritage = new Heritage(command.Description, command.PurchaseDate, command.Status, command.BarCode); AddNotifications(heritage); if (Invalid) { return(new CommandResult(MessagesUtil.CreatedError, false, Notifications)); } _repository.Create(heritage); return(new CommandResult(MessagesUtil.CreatedSuccess, true)); }
// GET: Heritages/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Heritage heritage = db.Heritage.Find(id); if (heritage == null) { return(HttpNotFound()); } return(View(heritage)); }
async Task <Repost> HeritagePutRequest(Heritage heritage) { heritage.SerializeCode = false; var data = JsonConvert.SerializeObject(heritage); var content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClient.PutAsync($"{ApiBaseUrl}heritages/{heritage.Id}", content); var repostage = await response.Content.ReadAsStringAsync(); Repost repost = JsonConvert.DeserializeObject <Repost>(repostage); repost.Success = response.IsSuccessStatusCode; return(repost); }
// GET: Heritages/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Heritage heritage = db.Heritage.Find(id); if (heritage == null) { return(HttpNotFound()); } ViewBag.EcoleID = new SelectList(db.Ecole, "EcoleID", "Nom", heritage.EcoleID); return(View(heritage)); }
public void Create(Heritage heritage) { _db.Connection().Execute( "spCreateHeritage", new { id = heritage.Id, description = heritage.Description, purchaseDate = heritage.PurchaseDate, status = heritage.Status, barCode = heritage.BarCode }, commandType: CommandType.StoredProcedure ); }
public async Task <bool> PutAsync(Heritage heritage) { Repost repost = new Repost(); try { var func = new Func <Task <Repost> >(() => HeritagePutRequest(heritage)); repost = await _networkService.Retry(func, 3, OnRetry); } catch (Exception ex) { throw ex; } return(repost.Success); }
public async Task <bool> DeleteAsync(Heritage heritage) { bool delete = false; try { var func = new Func <Task <bool> >(() => HeritageDeleteRequest(heritage.Id)); delete = await _networkService.Retry(func, 3, OnRetry); } catch (Exception ex) { throw ex; } return(delete); }
public IActionResult RemovePhoto([FromBody] Heritage heritage) { AppSettings appSettings = heritageRepository.GetAppSettings(_config); string folderPath = _environment.WebRootPath; RetSimple retVal = new RetSimple { success = false, message = "There was problem to remove photo." }; //string card_id = ""; if (heritage?.hers != null && heritage?.hers.Count > 0) { retVal = heritageRepository.RemovePhoto((heritage.hers[0]).id, folderPath, appSettings.emptyPhoto); } return(new JsonResult(retVal)); }
private void SaveHeritage() { var headBlendData = Game.PlayerPed.GetHeadBlendData(); var saveHeritage = new Heritage { Created = this.activeCharacter.Heritage.Created, Parent1 = headBlendData.FirstFaceShape, Parent2 = headBlendData.SecondFaceShape, Resemblance = headBlendData.ParentFaceShapePercent, SkinTone = headBlendData.ParentSkinTonePercent }; this.Logger.Debug($"Heritage Save: {saveHeritage}"); this.Rpc.Event(CharacterEvents.SaveHeritage).Trigger(this.activeCharacter.Id, saveHeritage); }
public override void Initialize(INavigationParameters parameters) { CurrentUser = new User(); UserJson = new UserJson(); IconTheme = new IconTheme(); Maintenance = new Maintenance(); Heritage = new Heritage(); Body = true; CurrentUser = UserJson.GetUsuarioJson(); Icone = IconTheme.IconName("tools"); if (parameters.ContainsKey("heritage")) { Heritage = (Heritage)parameters["heritage"]; } Maintenance.CompanyId = Heritage.CompanyId; Maintenance.Code = Heritage.Code; Maintenance.HeritageId = Heritage.Id; }
public void ShouldReturnValidWhenHeritageIsValid() { var heritage = new Heritage("Heritage", DateTime.Now, EHeritageStatus.Aviable, ""); Assert.AreEqual(true, heritage.Valid); }
public void Create(Heritage heritage) { }
public void ShouldReturnInvalidWhenPassingGuidWithEmptyDescription() { var heritage = new Heritage(Guid.NewGuid(), "", DateTime.Now, EHeritageStatus.Aviable, ""); Assert.AreNotEqual(true, heritage.Valid); }
public IActionResult GetHreitageById(int user_id, int herUserId) { Heritage heritage_ = heritageRepository.GetHeritageById(user_id, herUserId); return(Json(new { success = heritage_.success, heritage = heritage_, message = heritage_.message })); }
public void ShouldReturnInvalidWhenDescriptionIsEmpty() { var heritage = new Heritage("", DateTime.Now, EHeritageStatus.Aviable, ""); Assert.AreEqual(true, heritage.Invalid); }
public ICommandResult Handle(EditHeritageCommand command) { var heritage = new Heritage(command.Id, command.Description, command.PurchaseDate, command.Status, command.BarCode); throw new System.NotImplementedException(); }