public IActionResult UpdateBirtdate([FromRoute] int birthDateId, [FromBody] BirthdateUpdateRequest req)
 {
     try
     {
         _birthdateRepository.Update(req);
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(500, e));
     }
 }
示例#2
0
        private void UpdateRecord()
        {
            BirthdateUpdateRequest req = new BirthdateUpdateRequest();

            Console.Write("Provide Record ID: ");
            req.Id = int.Parse(Console.ReadLine());
            BirthdateResponse res = _repo.GetRecordById(req.Id);

            Console.Write($"Full Name({res.FullName}): ");
            req.FullName = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(req.FullName))
            {
                req.FullName = res.FullName;
            }
            Console.Write($"Date of Birth({res.Dob}): ");
            if (DateTime.TryParse(Console.ReadLine(), out var dob))
            {
                req.Dob = dob;
            }
            else
            {
                req.Dob = res.Dob;
            }
            Console.Write($"Date of Death({res.Dod}): ");
            if (DateTime.TryParse(Console.ReadLine(), out var dod))
            {
                req.Dod = dod;
            }
            else
            {
                req.Dod = res.Dod;
            }
            Console.Write($"Notoriety({res.Notoriety}): ");
            req.Notoriety = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(req.Notoriety))
            {
                req.Notoriety = res.Notoriety;
            }
            _repo.Update(req);
        }