public async Task <IActionResult> UpdateActor(ActorDto actor) { Logger.Here().Info("{UpdateActor} - Actor with {Id}", nameof(UpdateActor), actor.Id); var result = await _service.CreateMovieService().UpdateActorAsync(actor); return(GetUpdatedStatus(result, "Given actor is not updateable.")); }
private void SpawnActor(ActorDto actorDto) { GameObject actorObj = Instantiate(_actorTemplate, actorDto.Position, Quaternion.identity); Actor actor = actorObj.GetComponent <Actor>(); actor.Initialize(actorDto); }
public IActionResult Post([FromBody] ActorDto dto) { try { addActors.Execute(dto); return(StatusCode(201)); } catch (EntityAlreadyExistsException e) { return(StatusCode(409, new { Errors = new List <string> { e.Message } })); } catch (Exception e) { return(StatusCode(500, new { Errors = new List <string> { e.Message } })); } }
private IEnumerable <ShowDto> GetExpectedShows() { var show1 = new ShowDto { Id = 1, Name = "Matrix" }; var show2 = new ShowDto { Id = 2, Name = "Kill Bill" }; var actor1 = new ActorDto { Id = 1, Name = "Bill", Birthday = "1980-07-01" }; var actor2 = new ActorDto { Id = 3, Name = "Nick", Birthday = "1981-07-01" }; var actor3 = new ActorDto { Id = 2, Name = "Tom", Birthday = "1979-07-01" }; show1.Cast = new List <ActorDto>(); //show1.Cast = new List<ActorDto> { actor1 }; //show2.Cast = new List<ActorDto> { actor2, actor3 }; return(new List <ShowDto> { show1 }); }
public async Task <IActionResult> CreateActor(ActorDto actor) { Logger.Here().Info("{CreateActor} - {Actor}", nameof(CreateActor), actor); var result = await _service.CreateMovieService().AddActorAsync(actor); return(GetCreatedStatus(result, null, "Given actor is not addable.")); }
public IActionResult PutActor(int id, ActorDto dto) { dto.Id = id; _actorService.Update(dto); return(NoContent()); }
public async Task GetActorById__WhenActorExists_ReturnsProperData() { //Arrange var actor = new Actor { Id = 5, FirstName = "Al", LastName = "Pacino" }; var mock = new List <Actor> { actor }.AsQueryable().BuildMock(); _mockActorRepository.Setup(x => x.GetAll()).Returns(mock.Object); //ACT ActionResult <ActorDto> result = await _controller.GetActor(actor.Id); //ASSERT OkObjectResult okObjectResult = Assert.IsType <OkObjectResult>(result.Result); ActorDto actorDto = Assert.IsAssignableFrom <ActorDto>(okObjectResult.Value); Assert.Equal(actor.Id, actorDto.Id); Assert.Equal(actor.FirstName, actorDto.FirstName); Assert.Equal(actor.LastName, actorDto.LastName); }
public IActionResult EditActor([FromBody] ActorDto actor) { if (actor == null) { return(BadRequest(new { message = "Please check input." })); } var result = _personHelper.EditActor(actor); if (Guid.TryParse(result, out Guid Id)) { return(Ok(Id)); } else if (result.Equals(ErrorMessages.ACTOR_NOT_FOUND) || result.Equals(ErrorMessages.NAME_EMPTY) || result.Equals(ErrorMessages.SEX_INVALID) || result.Equals(ErrorMessages.BIO_EMPTY) || result.Equals(ErrorMessages.DOB_INVALID) || result.Equals(ErrorMessages.DOB_LIMIT)) { return(BadRequest(new { message = result })); } else { return(StatusCode(500, new { message = result })); } }
public IEnumerable <Transition> GetTransition(ActorDto dto) { WorkflowInstance instance = WorkflowInstance.GetInstance(dto.ID); var current = GetCurrent(instance, dto.ActorID); return(NodeService.GetExecuteTransition(current)); }
public ActorDto AddActor(ActorDto actorDto) { var actor = _context.Add(_mapper.Map <Actor>(actorDto)).Entity; _context.SaveChanges(); return(_mapper.Map <ActorDto>(actor)); }
public ActorDto UpdateActor(ActorDto actorDto) { if (actorDto.Id == null) { return(null); } try { var actor = _mapper.Map <Actor>(actorDto); _context.Update(actor); _context.SaveChanges(); return(_mapper.Map <ActorDto>(actor)); } catch (DbUpdateException) { if (!ActorExists((int)actorDto.Id)) { return(null); } return(null); } }
public ActorDto UpdateActor(ActorDto actorDto) { if (actorDto.Id == null) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } try { var actor = _mapper.Map <Actor>(actorDto); _context.Update(actor); _context.SaveChanges(); return(_mapper.Map <ActorDto>(actor)); } catch (DbUpdateException) { if (!ActorExists((int)actorDto.Id)) { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } else { //упрощение для примера //лучше всего генерировать ошибки и обрабатывать их на уровне конроллера return(null); } } }
public ActionResult <Response <ActorDto> > CreateActor([FromBody] ActorDto actorDto, [FromQuery] List <int> movieIds) { try { ValidateActor(actorDto, movieIds); var actor = _service.CreateActor(actorDto, movieIds); Response <ActorDto> response = new Response <ActorDto> { Payload = new Payload <ActorDto> { PayloadObject = new ActorDto { Id = actor.Id, LastName = actor.LastName, Name = actor.Name, Picture = actor.Picture, DateOfBirth = actor.DateOfBirth } } }; return(CreatedAtRoute("GetActor", new { actorId = actor.Id }, response)); } catch (ErrorDetails ex) { _logger.LogError(ex.Description, ex); Response <ActorDto> resp = new Response <ActorDto> { Payload = null, Exception = ex }; return(resp); } }
public ActionResult Create(ActorDto dto) { if (!ModelState.IsValid) { TempData["error"] = "Check your input."; return(RedirectToAction(nameof(Create))); } try { executor.ExecuteCommand(addActor, dto); TempData["success"] = Messages.CREATE_SUCCESS; return(RedirectToAction(nameof(Index))); } catch (EntityNotAllowedException) { return(RedirectToAction("PageNotFound", "Redirections")); } catch (EntityAlreadyExistsException e) { TempData["error"] = e.Message; } catch (Exception e) { TempData["error"] = e.Message; } return(RedirectToAction(nameof(Index))); }
public string EditActor(ActorDto actor) { var checkExists = _movieAppRepository.GetActor(actor.Name); if (checkExists == null) { return(ErrorMessages.ACTOR_NOT_FOUND); } var result = ValidatePersonForEdit(actor.Name, actor.Sex, actor.Bio, actor.DOB); if (result.Equals(String.Empty)) { var editedActor = _movieAppRepository.EditActor(checkExists.Id, actor); if (editedActor != null) { return(editedActor.Id.ToString()); } else { return(ErrorMessages.SERVER_ERROR); } } else { return(result); } }
public string AddActor(ActorDto actor) { var checkExists = _movieAppRepository.GetActor(actor.Name); if (checkExists != null) { return(ErrorMessages.ACTOR_ALREADY_EXISTS); } var result = ValidatePersonForAdd(actor.Name, actor.Sex, actor.Bio, actor.DOB); if (result.Equals(String.Empty)) { var newActor = _movieAppRepository.AddActor(actor); if (newActor != null) { return(newActor.Id.ToString()); } else { return(ErrorMessages.SERVER_ERROR); } } else { return(result); } }
public void Initialize(ActorDto actorDto) { Guid = Guid.Parse(actorDto.Guid); gameObject.name = Guid.ToString(); gameObject.tag = FactionType.ToString(); FactionType = actorDto.FactionType; Playable = actorDto.Playable; TaskScheduler.Initialize(Guid); StatusEffectScheduler.Initialize(Guid); Attributes.Initialize(this, actorDto.AttributesDto); Status.Initialize(actorDto.StatusDto); Inventory.Initialize(actorDto.InventoryDto); Armory.Initialize(this, actorDto.ArmoryDto); Skills.Initialize(actorDto.SkillsDto); SkinnedMeshRenderer skinnedMeshRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); Face.Initialize(skinnedMeshRenderer, actorDto.FeaturesDto); Body.Initialize(skinnedMeshRenderer, actorDto.FeaturesDto); if (Playable) { Squad.AddToSquad(this); } }
public SimpleResponse <ActorDto> Create(ActorDto dto) { var response = new SimpleResponse <ActorDto>(); try { var model = SimpleMapper.Map <ActorDto, ActorViewModel>(dto); var resp = iActorBusiness.Create(model); response = new SimpleResponse <ActorDto>() { ResponseCode = resp.ResponseCode, ResponseMessage = resp.ResponseMessage, RCode = resp.RCode }; response.Data = SimpleMapper.Map <ActorViewModel, ActorDto>(resp.Data); } catch (Exception ex) { response.ResponseCode = BusinessResponseValues.InternalError; response.ResponseMessage = "Okuma iþleminde hata oluþtu."; SimpleFileLogger.Instance.Error(ex); } return(response); }
public int GetNodeCooperation(ActorDto dto) { WorkflowInstance instance = WorkflowInstance.GetInstance(dto.ID); Node current = GetCurrent(instance, dto.ActorID); return(String.IsNullOrEmpty(current.Cooperation)?0:1); }
public ActorDto Add(ActorDto actorDto) { var actor = _mapper.Map <Actor>(actorDto); _context.Actors.Add(actor); _context.SaveChanges(); actorDto.Id = actor.Id; return(actorDto); }
public void Execute(ActorDto request) { var actor = mapper.Map <Actor>(request); validator.ValidateAndThrow(request); context.Actors.Add(actor); context.SaveChanges(); }
public void Execute(ActorDto request) { var actorFromDb = context.Genres.Find(request.Id); mapper.Map(request, actorFromDb); validator.ValidateAndThrow(request); context.SaveChanges(); }
public static ActorDto MapActor(Actor actor) { var actorDto = new ActorDto(); actorDto.Id = actor.Id; actorDto.Name = actor.Name; actorDto.LastUpdatedDate = actor.LastUpdatedDate; actorDto.CreatedDate = actor.CreatedDate; return(actorDto); }
[HttpPut("{id}")] // PUT: api/actors/5 public IActionResult UpdateActor(int id, ActorDto editDto) { var actor = _service.UpdateActor(editDto); if (actor == null) { return(BadRequest()); } return(Ok(actor)); }
public Actor CreateActor(ActorDto actorDto, List <int> movieIds) { var actorObj = _mapper.Map <Actor>(actorDto); if (!_repo.CreateActor(actorObj, movieIds)) { throw new Exception($"Something went wrong when saving the record {actorObj.Name}"); } return(actorObj); }
// PUT: api/Actor/5 public IHttpActionResult Put(ActorDto actor) { var updatedActor = _actorsServices.UpdateActor(actor); if (updatedActor == null) { return(NotFound()); } return(Ok(updatedActor)); }
public Actor AddActor(ActorDto actor) { var newActor = AutoMapper.Mapper.Map <Actor>(actor); _context.Actors.Add(newActor); if (Save()) { return(newActor); } return(null); }
public void AddActor(Actor actor) { IActorContext db = DataFactory.DataFactory.GetActorContext(); ActorDto actorDto = DataFactory.DataFactory.GetActorDto(); actorDto.ActorId = actor.ActorId; actorDto.ActorName = actor.ActorName; actorDto.ActorInfo = actor.ActorInfo; db.AddActor(actorDto); }
public ActorDto CreateActors(ActorDto actor) { var entity = new Actor { Name = actor.Name, Films = Mapper.Map <ICollection <Films> >(actor.FilmsDto) }; Insert(entity); Work.Db.SaveChanges(); return(Mapper.Map <ActorDto>(entity)); }
public ActorDto UpdateActor(ActorDto actor) { var IsExist = Exists <Actor>(Mapper.Map <Actor>(actor)); if (IsExist) { return(null); } Update(Mapper.Map <Actor>(actor)); Work.Db.SaveChanges(); return(actor); }