public ActionResult <Apartments> Create(Apartments apartment)
        {
            apartment.id = new Random().Next();
            _apartmentsService.Create(apartment);

            return(CreatedAtRoute("Details", new { id = apartment.objectId.ToString() }, apartment));
        }
 public IActionResult Create(Apartments apartments)
 {
     if (ModelState.IsValid)
     {
         apartments.id = new Random().Next();
         _apartmentsService.Create(apartments);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(apartments));
 }