Beispiel #1
0
 public IActionResult UpdateValuer(int id, ValuerRequestDto updateValuer)
 {
     if (_service.UpdateValuer(id, updateValuer))
     {
         return(Ok("Valuer sucessfully update!!!"));
     }
     else
     {
         return(BadRequest("Valuer could not be UPDATED!!! Something went wrong..."));
     }
 }
Beispiel #2
0
 public IActionResult AddValuer(ValuerRequestDto newValuer)
 {
     if (_service.AddValuer(newValuer))
     {
         return(Ok("New Valuer CREATED!!!"));
     }
     else
     {
         return(BadRequest("Valuer could not be CREATED!!! Something went wrong..."));
     }
 }
Beispiel #3
0
 public bool AddValuer(ValuerRequestDto newValuer)
 {
     try
     {
         //var newId = _context.Rzeczoznawca.Max(u => u.Id) + 1;
         var valuerToAdd = new Rzeczoznawca
         {
             //Id = newId,
             Nr       = newValuer.Number,
             Imie     = newValuer.FirstName,
             Nazwisko = newValuer.LastName,
             Mail     = newValuer.Mail
         };
         _context.Add(valuerToAdd);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        public bool UpdateValuer(int id, ValuerRequestDto updateValuer)
        {
            var valuerToUpdate = _context.Rzeczoznawca.Where(v => v.Id == id).SingleOrDefault();

            if (valuerToUpdate == null)
            {
                return(false);
            }

            try
            {
                valuerToUpdate.Imie     = updateValuer.FirstName;
                valuerToUpdate.Nazwisko = updateValuer.LastName;
                valuerToUpdate.Mail     = updateValuer.Mail;
                valuerToUpdate.Nr       = updateValuer.Number;
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }