Beispiel #1
0
        public async Task <CommercialProperty> AddIndustrialProperty(CommercialProperty property)
        {
            if (property != null)
            {
                property.IsActive = true;

                IFormFile[] files     = new IFormFile[] { property.imageFile1, property.imageFile2, property.imageFile3, property.imageFile4 };
                string[]    fileLinks = new string[] { property.ImageLink1, property.ImageLink2, property.ImageLink3, property.ImageLink4 };

                for (int i = 0; i < files.Length; i++)
                {
                    if (files[i] == null)
                    {
                        fileLinks[i] = "#";
                    }
                    else
                    {
                        fileLinks[i] = GetFileUploadBlobReturnsLink(files[i]);
                    }
                }

                property.ImageLink1 = fileLinks[0];
                property.ImageLink2 = fileLinks[1];
                property.ImageLink3 = fileLinks[2];
                property.ImageLink4 = fileLinks[3];

                _db.CommercialProperties.Add(property);
                await _db.SaveChangesAsync();

                return(property);
            }

            return(null);
        }
Beispiel #2
0
        public async Task <CommercialProperty> EditCommercialProperty(int id, CommercialProperty property)
        {
            CommercialProperty commercialProperty = null;

            commercialProperty    = _db.CommercialProperties.AsNoTracking().FirstOrDefault(m => m.Id == id);
            commercialProperty    = property;
            commercialProperty.Id = id;

            _db.CommercialProperties.Update(commercialProperty);
            await _db.SaveChangesAsync();

            return(commercialProperty);
        }
Beispiel #3
0
        // [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
        public async Task <IActionResult> EditCommercialProperty([FromRoute] int id, [FromBody] CommercialProperty property)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _manager.EditCommercialProperty(id, property);

            if (result != null)
            {
                return(Ok(result));
            }

            return(BadRequest());
        }
Beispiel #4
0
        // [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
        public async Task <IActionResult> AddCommercialProperty([FromForm] CommercialProperty property)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _manager.AddIndustrialProperty(property);

            if (result != null)
            {
                return(Ok(result));
            }

            return(BadRequest());
        }