public async Task <IActionResult> Post([FromForm] AddPropertyRequestModel model) { int?id; var businessModel = _mapper.Map <AddPropertyRequestDto>(model); try { id = await _service.AddAsync(UserInfo.AgencyId, businessModel); } finally { foreach (var item in businessModel.AttachmentsToAdd) { item.Stream.Dispose(); } } return(Created(Url.RouteUrl(id), id)); }
public IActionResult AddClassProperty([FromRoute] string languageId, [FromRoute] string classname, [FromBody] KProperty kProperty) { try { var userId = string.Empty; userId = AuthHelper.AuthorizeRequest(Request); var tempCommand = new AddPropertyRequestModel() { Property = kProperty, ClassName = classname, UserId = userId, LanguageId = languageId }; List <System.ComponentModel.DataAnnotations.ValidationResult> validationResult = new List <System.ComponentModel.DataAnnotations.ValidationResult>(); if (kProperty == null) { validationResult.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Property can not be null")); } else if (string.IsNullOrEmpty(kProperty.Name)) { validationResult.Add(new System.ComponentModel.DataAnnotations.ValidationResult("Property name can not be null")); } if (validationResult.Any()) { return(BadRequest(validationResult)); } return(Ok(MongoConnector.AddPropertyToClass(tempCommand))); } catch (Exception ex) { return(BadRequest(ex)); } }