public BaseResponse Add(Actor actor)
 {
     return(DoSuccess(() =>
     {
         _service.Add(actor);
     }));
 }
Esempio n. 2
0
 private void AddActor()
 {
     _actorService.Add(new Actor
     {
         Name     = txtActorName.Text,
         SurName  = txtActorSurName.Text,
         BirthDay = dtpBirthDay.Value.Date
     });
     GetAllActor();
 }
        public IActionResult Add(Actor actor)
        {
            var result = _actorService.Add(actor);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Esempio n. 4
0
        public IActionResult NewActor(PersonViewModel personVm)
        {
            if (!ModelState.IsValid)
            {
                personVm.SexOptions = _genders;
                return(View("NewActor", personVm));
            }

            var gender = _genderDbService.GetGenders().FirstOrDefault(x => x.Description == personVm.Sex);

            var newActor = new Actor()
            {
                FirstName  = personVm.FirstName,
                MiddleName = personVm.MiddleName,
                LastName   = personVm.LastName,
                DOB        = personVm.DOB,
                Bio        = personVm.Bio,
                Sex        = gender
            };

            try
            {
                _actorDbService.Add(newActor);
            }
            catch (ArgumentException argEx)
            {
                return(RedirectToAction("Error", "Listing", new { message = argEx.Message }));
            }
            catch (Exception ex)
            {
                // Log exception and display friendly message to user
                return(RedirectToAction("Error", "Listing", new { message = "Looks like something went wrong" }));
            }

            var actor = _actorDbService.GetActor(newActor.FirstName, newActor.MiddleName, newActor.LastName, newActor.DOB, newActor.Sex);

            if (actor != null)
            {
                return(RedirectToAction("Detail", "Actor", new { id = actor.Id }));
            }

            return(RedirectToAction("Index", "Actor"));
        }
Esempio n. 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Actor actorModel = new Actor();

            actorModel.Name     = txtActorName.Text;
            actorModel.SurName  = txtActorSurName.Text;
            actorModel.IsActive = checkActor.Checked;
            if (uploadActor.HasFile)
            {
                var      fileName    = uploadActor.FileName;
                FileInfo fileInfo    = new FileInfo(fileName);
                var      extension   = fileInfo.Extension;
                var      newFileName = $"{Guid.NewGuid()}{extension}";
                string   path        = $"{Server.MapPath("~/Uploads")}/{newFileName}";
                uploadActor.SaveAs(path);
                actorModel.CoverImage = newFileName;
            }
            _actorManager.Add(actorModel);
            EditActorEmpty();
            LoadListOfActors();
        }
Esempio n. 6
0
        public ActionResult <ActorDto> PostActor(ActorDto dto)
        {
            _actorService.Add(dto);

            return(CreatedAtAction("GetActor", new { id = dto.Id }, dto));
        }
 public IActionResult Create(Actor actor)
 {
     _actorService.Add(actor);
     return(RedirectToAction(nameof(Index)));
 }
 public IActionResult Post([FromBody] Actor Actor)
 {
     return(Ok(_actorService.Add(Actor)));
 }
Esempio n. 9
0
 public IActionResult Post([FromBody] Actor Model)
 {
     return(Json(
                _actorService.Add(Model)
                ));
 }