diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs
index bf8fa76..21daf5b 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -462,6 +462,52 @@ namespace ManagerService.Controllers
}
}
+ ///
+ /// Update sections order
+ ///
+ /// New sections order
+ [ProducesResponseType(typeof(string), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPut("order")]
+ public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder)
+ {
+ try
+ {
+ if (updatedSectionsOrder == null)
+ throw new ArgumentNullException("Sections param is null");
+
+ foreach (var section in updatedSectionsOrder)
+ {
+ if (!_sectionService.IsExist(section.Id))
+ throw new KeyNotFoundException($"Section {section.Label} with id {section.Id} does not exist");
+ }
+
+ foreach (var updatedSection in updatedSectionsOrder)
+ {
+ Section section = _sectionService.GetById(updatedSection.Id);
+ section.Order = updatedSection.Order;
+
+ _sectionService.Update(section.Id, section);
+ }
+
+ return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 };
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
///
/// Delete a section