Beispiel #1
0
        public async Task <SharedLookUpResponse> AddIssueBookAsync(AddIssueBook addIssueBook, int institudeId)
        {
            if (!await iMSDbContext.IssueBooks.AnyAsync(x => x.InstituteId == institudeId && x.BookId == addIssueBook.BookId && x.StudentId == addIssueBook.StudentId && x.StaffId == addIssueBook.StaffId))
            {
                var issueBook = new IssueBook()
                {
                    InstituteId = institudeId,
                    UserType    = addIssueBook.UserType,
                    StudentId   = addIssueBook.StudentId,
                    StaffId     = addIssueBook.StaffId,
                    BookId      = addIssueBook.BookId,
                    IssueDate   = addIssueBook.IssueDate,
                    RefNo       = addIssueBook.RefNo,
                    Status      = 0,
                    Description = addIssueBook.Description
                };
                iMSDbContext.IssueBooks.Add(issueBook);
                await iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Issue Book added successfully"
                });
            }
            else
            {
                return(new SharedLookUpResponse()
                {
                    HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Issue Book with same info is already existed"
                });
            }
        }
Beispiel #2
0
        public async Task <IActionResult> AddIssueBookAsync([FromBody] AddIssueBook addGroupAc)
        {
            if (addGroupAc.IssueDate == null)
            {
                return(Ok(new SharedLookUpResponse()
                {
                    HasError = true,
                    ErrorType = SharedLookUpResponseType.Name,
                    Message = "Issue date can't be null or empty"
                }));
            }
            else if (string.IsNullOrEmpty(addGroupAc.RefNo.Trim()))
            {
                return(Ok(new SharedLookUpResponse()
                {
                    HasError = true,
                    ErrorType = SharedLookUpResponseType.Name,
                    Message = "Issue No can't be null or empty"
                }));
            }
            else
            {
                await bookManagementRepository.IssueBookAsync(addGroupAc.BookId);

                return(Ok(await issueBookManagementRepository.AddIssueBookAsync(addGroupAc, await GetUserCurrentSelectedInstituteIdAsync())));
            }
        }