public bool AddRealEstateDetails(RealEstateDetail details)
 {
     try
     {
         _context.RealEstateDetail.Add(details);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// function nay lam cai me gi vay nhi
        /// </summary>
        /// <param name="details"></param>
        /// <param name="agentId"></param>
        /// <returns></returns>
        public int AddCompleteRealEstate(VM_RealEstateDetails details, int agentId)
        {
            var realEstate = new RealEstate()
            {
                PostTime         = DateTime.Now,
                LastUpdate       = DateTime.Now,
                BeginTime        = Convert.ToDateTime(details.BeginTime),
                ExprireTime      = Convert.ToDateTime(details.ExprireTime),
                RealEstateTypeId = details.RealEstateTypeId,
                AgentId          = agentId,
                ContactNumber    = details.ContactNumber,
                IsActive         = false,
                IsConfirm        = agentId == 1,
                IsAvaiable       = true,
                ConfirmStatus    = agentId == 1 ? 1 : 0
            };
            var realEstateId = AddNewRealEstate(realEstate);

            //tao real estate thanh cong
            if (realEstateId != -1)
            {
                //add details
                var rtDetails = new RealEstateDetail()
                {
                    RealEstateId    = realEstateId,
                    Title           = details.Title,
                    Price           = details.Price,
                    Acreage         = details.Acreage,
                    RoomNumber      = details.RoomNumber,
                    Description     = details.Description,
                    HasPrivateWc    = details.HasPrivateWc,
                    HasMezzanine    = details.HasMezzanine,
                    AllowCook       = details.AllowCook,
                    FreeTime        = details.FreeTime,
                    SecurityCamera  = details.SecurityCamera,
                    WaterPrice      = details.IsFreeWater ? 0 : Convert.ToInt32(details.WaterPrice),
                    ElectronicPrice = details.IsFreeElectronic ? 0 : Convert.ToInt32(details.ElectronicPrice),
                    WifiPrice       = details.IsFreeWifi ? 0 : details.WifiPrice
                };

                var isSuccessAddDetails = AddRealEstateDetails(rtDetails);

                //add map
                var map = new Map()
                {
                    Address      = details.Address,
                    Latitude     = details.Latitude,
                    Longtitude   = details.Longtitude,
                    RealEstateId = realEstateId
                };
                var isSuccessAddMap = AddMapForRealEstate(map);

                //neu add thong tin chi tiet va map thanh cong thi active
                if (isSuccessAddDetails && isSuccessAddMap)
                {
                    ActiveRealEstate(realEstateId);
                    return(realEstateId);
                }
                else
                {
                    return(-1);
                }
            }

            return(realEstateId);
        }