diff --git a/server/AyaNova/Controllers/DataListViewController.cs b/server/AyaNova/Controllers/DataListViewController.cs
index d14f32ba..19209da9 100644
--- a/server/AyaNova/Controllers/DataListViewController.cs
+++ b/server/AyaNova/Controllers/DataListViewController.cs
@@ -168,7 +168,40 @@ namespace AyaNova.Api.Controllers
}
+ ///
+ /// Duplicate DataListView
+ ///
+ /// Create a duplicate of this items id
+ /// Automatically filled from route path, no need to specify in body
+ ///
+ [HttpPost("duplicate/{id}")]
+ public async Task Duplicate([FromRoute] long id, ApiVersion apiVersion)
+ {
+ if (!serverState.IsOpen)
+ return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
+ //Instantiate the business object handler
+ DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
+
+ //If a user has change roles
+ if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
+ return StatusCode(403, new ApiNotAuthorizedResponse());
+
+ if (!ModelState.IsValid)
+ return BadRequest(new ApiErrorResponse(ModelState));
+
+ var oSrc = await biz.GetAsync(id, false);
+ if (oSrc == null)
+ return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
+
+ //Create and validate
+ DataListView o = await biz.DuplicateAsync(oSrc);
+ if (o == null)
+ return BadRequest(new ApiErrorResponse(biz.Errors));
+ else
+ return CreatedAtAction(nameof(DataListViewController.GetDataListView), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
+
+ }
///
/// Delete DataListView
diff --git a/server/AyaNova/biz/DataListViewBiz.cs b/server/AyaNova/biz/DataListViewBiz.cs
index f2d0d3c9..ad89a7dc 100644
--- a/server/AyaNova/biz/DataListViewBiz.cs
+++ b/server/AyaNova/biz/DataListViewBiz.cs
@@ -76,6 +76,32 @@ namespace AyaNova.Biz
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ //DUPLICATE
+ //
+
+ internal async Task DuplicateAsync(DataListView dbObj)
+ {
+
+ DataListView outObj = new DataListView();
+ CopyObject.Copy(dbObj, outObj);
+ outObj.Name = Util.StringUtil.NameUniquify(outObj.Name, 255);
+ outObj.Id = 0;
+ outObj.ConcurrencyToken = 0;
+
+
+
+ await ct.DataListView.AddAsync(outObj);
+ await ct.SaveChangesAsync();
+
+ //Handle child and associated items:
+ await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
+
+ return outObj;
+
+ }
+
////////////////////////////////////////////////////////////////////////////////////////////////
/// GET