Release v1.0.0 #16
@@ -15,6 +15,11 @@ public class GroupDetailsResponse
 | 
				
			|||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public required string Name { get; set; }
 | 
					    public required string Name { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Gets or sets the course number of the group.
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public int CourseNumber { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// Gets or sets the unique identifier of the faculty to which the group belongs (optional).
 | 
					    /// Gets or sets the unique identifier of the faculty to which the group belongs (optional).
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,11 @@ public class GroupResponse
 | 
				
			|||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    public required string Name { get; set; }
 | 
					    public required string Name { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Gets or sets the course number of the group.
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public int CourseNumber { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// <summary>
 | 
					    /// <summary>
 | 
				
			||||||
    /// Gets or sets the unique identifier of the faculty to which the group belongs (optional).
 | 
					    /// Gets or sets the unique identifier of the faculty to which the group belongs (optional).
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ using Mirea.Api.DataAccess.Application.Cqrs.Group.Queries.GetGroupDetails;
 | 
				
			|||||||
using Mirea.Api.DataAccess.Application.Cqrs.Group.Queries.GetGroupList;
 | 
					using Mirea.Api.DataAccess.Application.Cqrs.Group.Queries.GetGroupList;
 | 
				
			||||||
using Mirea.Api.Dto.Responses;
 | 
					using Mirea.Api.Dto.Responses;
 | 
				
			||||||
using Mirea.Api.Endpoint.Common.Attributes;
 | 
					using Mirea.Api.Endpoint.Common.Attributes;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
@@ -13,6 +14,19 @@ namespace Mirea.Api.Endpoint.Controllers.V1
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public class GroupController(IMediator mediator) : BaseControllerV1
 | 
					    public class GroupController(IMediator mediator) : BaseControllerV1
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        private static int GetCourseNumber(string groupName)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var current = DateTime.Now;
 | 
				
			||||||
 | 
					            if (!int.TryParse(groupName[2..], out var yearOfGroup)
 | 
				
			||||||
 | 
					                && !int.TryParse(groupName.Split('-')[^1][..2], out yearOfGroup))
 | 
				
			||||||
 | 
					                return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Convert a two-digit year to a four-digit one
 | 
				
			||||||
 | 
					            yearOfGroup += current.Year / 100 * 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return current.Year - yearOfGroup + (current.Month < 9 ? 0 : 1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Retrieves a list of groups.
 | 
					        /// Retrieves a list of groups.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@@ -35,7 +49,8 @@ namespace Mirea.Api.Endpoint.Controllers.V1
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    Id = g.Id,
 | 
					                    Id = g.Id,
 | 
				
			||||||
                    Name = g.Name,
 | 
					                    Name = g.Name,
 | 
				
			||||||
                    FacultyId = g.FacultyId
 | 
					                    FacultyId = g.FacultyId,
 | 
				
			||||||
 | 
					                    CourseNumber = GetCourseNumber(g.Name)
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -61,7 +76,8 @@ namespace Mirea.Api.Endpoint.Controllers.V1
 | 
				
			|||||||
                Id = result.Id,
 | 
					                Id = result.Id,
 | 
				
			||||||
                Name = result.Name,
 | 
					                Name = result.Name,
 | 
				
			||||||
                FacultyId = result.FacultyId,
 | 
					                FacultyId = result.FacultyId,
 | 
				
			||||||
                FacultyName = result.Faculty
 | 
					                FacultyName = result.Faculty,
 | 
				
			||||||
 | 
					                CourseNumber = GetCourseNumber(result.Name)
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user