public async Task <IActionResult> PostAddPropertyAsync([FromBody] PropertyModel obj) { if (!ModelState.IsValid) { return(BadRequest()); } var response = await _propertyService.AddPropertyAsync(obj); _responseModel.Status = response.Status; _responseModel.Message = response.Message; if (_responseModel.Status) { return(Ok(_responseModel)); } else { return(BadRequest(_responseModel)); } }
public async Task <IActionResult> Create([Bind("propertyId,propertyClassId,propertyTypeId,propertyNum,propertySubNum,address1,address2,address3,address4,postCode,demolitionDate,creationDate,livingRoomQty,singleBedroomQty,doubleBedroomQty,maxOccupants,updatedByUserID,updatedDT,createdByUserID,createdDT")] PropertyViewModel propertyVM) { if (ModelState.IsValid) { DateTime recordDT = DateTime.Now; var _property = _mapper.Map <property>(propertyVM); //Map viewmodel to property model object var user = await _userManager.GetUserAsync(HttpContext.User); //Get logged in user //Set created by & updated by values for record _property.updatedByUserID = user.Id; _property.updatedDT = recordDT; _property.createdByUserID = user.Id; _property.createdDT = recordDT; await _propertySvc.AddPropertyAsync(_property); return(RedirectToAction(nameof(Index))); } ViewBag.propertyClassId = new SelectList(await _propertySvc.GetPropertyClassesAsync(), "propertyClassId", "propertyClass1", propertyVM.propertyClassId); ViewBag.propertyTypeId = new SelectList(await _propertySvc.GetPropertyTypesAsync(), "propertyTypeId", "propertyType1", propertyVM.propertyTypeId); return(View(propertyVM)); }