using CMSBLL.ContentType; using CMSDAL.CustomCode.ContentType; using CMSDAL.DTO.ContentType; using GB5Shared.DTO.Framework.AutoNumber; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.GenerateAutoNumber; using GB5Shared.Resource.Response; using GB5Shared.ResponseStandard; using GB5Shared.Validation; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FrameworkBLL.ContentType { public class ContentTypeBLL : IContentTypeBLL { private readonly IContentTypeDAL _ContentTypeDAL; private readonly AutoNumber _AutoNumber; private readonly IValidation _Validation; public ContentTypeBLL(IContentTypeDAL ContentTypeDAL, AutoNumber AutoNumber, IValidation Validation) { _ContentTypeDAL = ContentTypeDAL; _AutoNumber = AutoNumber; _Validation = Validation; } public async Task GetContentType(int ContentTypeId, LoginDTO LoginDTO) { try { return await _ContentTypeDAL.GetContentType(ContentTypeId, LoginDTO); } catch (Exception) { throw; } } public async Task SaveContentType(ContentTypeDTO ContentTypeDTO, LoginDTO LoginDTO) { //if (ContentTypeDTO == null) throw new ArgumentNullException(nameof(ContentTypeDTO)); //AutoNumberDTO? autoNumberDTO = null; try { ContentTypeDTO.ContentTypeModifiedById = LoginDTO.UserId; ContentTypeDTO.ContentTypeModifiedOn = DateTime.UtcNow; if (ContentTypeDTO.ContentTypeId == 0) { //autoNumberDTO = await _AutoNumber.GetAutoNumber(count, "ContentType", LoginDTO); //ContentTypeDTO.ContentTypeId = autoNumberDTO.StartNumber; ContentTypeDTO.ContentTypeCreatedById = LoginDTO.UserId; ContentTypeDTO.ContentTypeCreatedOn = DateTime.UtcNow; await _ContentTypeDAL.SaveContentType(ContentTypeDTO, LoginDTO); return $"{SuccessResponse.SaveSuccess}"; } else { await _ContentTypeDAL.UpdateContentType(ContentTypeDTO, LoginDTO); return $"{SuccessResponse.UpdateSuccess}"; } } catch (ValidationException vex) { throw new Exception(vex.Message); } catch (Exception) { //if (autoNumberDTO != null && ContentTypeDTO.ContentTypeId > 0) // await _AutoNumber.RollbackAutoNumber("ContentType", ContentTypeDTO.ContentTypeId, LoginDTO); throw; } } public async Task GetSelectListContentType(int FirstNumber, int MaxResult, CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { return await _ContentTypeDAL.GetSelectListContentType(FirstNumber, MaxResult, CriteriaDTO, LoginDTO); } catch (Exception) { throw; } } public async Task DeleteContentType(int ContentTypeId, LoginDTO LoginDTO) { try { return await _ContentTypeDAL.DeleteContentType(ContentTypeId, LoginDTO); } catch (Exception) { throw; } } public async Task GetContentTypeList(CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { return await _ContentTypeDAL.GetContentTypeList(CriteriaDTO, LoginDTO); } catch (Exception) { throw; } } } }