public async Task AddIssue_IssueIsValid_Returns_IssueDto()
        {
            var issueDto = new IssueDto();

            var issueResult = await _issueService.Add(issueDto);

            _issueRepositoryMock.Verify(x => x.Add(It.IsAny <Issue>()), Times.Once);
            _issueRepositoryMock.Verify(x => x.SaveChangesAsync(), Times.Once);
        }
Exemplo n.º 2
0
        protected void ButtonSubmitReturn_Click(object sender, EventArgs e)
        {
            if (BookIssuesReturn == null || BookIssuesReturn.Count == 0)
            {
                //info.InnerHtml = "Please choose book to issue";
                return;
            }
            student Student = (student)StudentService.GetById(TextBoxStudentID.Text);

            if (Student != null)
            {
                string IssueID = StringUtil.GenerateRandomNumber(9);
                issue  Issue   = new issue();
                Issue.user_id        = LoggedUser.id;
                Issue.id             = IssueID;
                Issue.type           = "return";
                Issue.date           = DateTime.Now;
                Issue.student_id     = Student.id;
                Issue.addtional_info = "RETURN INFO";

                if (null == IssueService.Add(Issue))
                {
                    AlertMessage("Gagal tambah issue");
                    return;
                }
                foreach (book_issue BS in BookIssuesReturn)
                {
                    BS.issue_id = Issue.id;
                    if (null == BookIssueService.Add(BS))
                    {
                        AlertMessage("Gagal tambah book_issue");
                        break;
                    }
                    book_record BR = (book_record)bookRecordService.GetById(BS.book_record_id);
                    BR.available               = 1;
                    BS.book_issue2             = (book_issue)BookIssueService.GetById(BS.book_issue_id);
                    BS.book_issue2.book_return = 1;

                    if (null == bookRecordService.Update(BR) || null == BookIssueService.Update(BS.book_issue2))
                    {
                        //info.InnerHtml = "Gagal update book_record ";
                        break;
                    }
                }
                ViewState["BookIssuesReturn"] = null;
                Issues           = new List <issue>();
                IssuesReturn     = new List <issue>();
                BookIssuesReturn = new List <book_issue>();
                PopulateBooksToReturn();
                AlertMessage("Sukses mengembalikan buku " + IssueID);
                //ButtonClearList_Click(sender, e);
            }
            else
            {
                AlertMessage("Siswa tdk ada");
            }
        }
Exemplo n.º 3
0
        protected void ButtonSaveIssue_Click(object sender, EventArgs e)
        {
            if (BookIssues == null || BookIssues.Count == 0)
            {
                info.InnerHtml = "Please choose book to issue";
                return;
            }
            student Student = (student)StudentService.GetById(TextBoxStudentID.Text);

            if (Student != null)
            {
                string IssueID = StringUtil.GenerateRandomNumber(9);
                issue  Issue   = new issue();
                Issue.user_id        = LoggedUser.id;
                Issue.id             = IssueID;
                Issue.type           = "issue";
                Issue.date           = DateTime.Now;
                Issue.student_id     = Student.id;
                Issue.addtional_info = "test";

                if (null == IssueService.Add(Issue))
                {
                    AlertMessage("Gagal tambah issue");
                    return;
                }
                foreach (book_issue BS in BookIssues)
                {
                    //final check
                    if (bookRecordService.FindByIdFull(BS.book_record_id).available == 0)
                    {
                        continue;
                    }
                    BS.issue_id = Issue.id;
                    if (null == BookIssueService.Add(BS))
                    {
                        AlertMessage("Gagal tambah book_issue");
                        break;
                    }
                    book_record BR = (book_record)bookRecordService.GetById(BS.book_record_id);
                    BR.available = 0;

                    if (null == bookRecordService.Update(BR))
                    {
                        AlertMessage("Gagal update book_record ");
                        break;
                    }
                }

                ButtonClearList_Click(sender, e);
                AlertMessage("Sukses tambah issue " + IssueID);
            }
            else
            {
                AlertMessage("Siswa tdk ada");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtEmployeeCode.Text))
            {
                Ultils.SetColorErrorTextControl(txtEmployeeCode, "Vui lòng nhập vào Code của nhân viên");
            }
            else if (string.IsNullOrEmpty(txtEmployeeName.Text))
            {
                Ultils.SetColorErrorTextControl(txtEmployeeName, "Vui lòng nhập vào tên người yêu cầu!");
            }
            else if (string.IsNullOrEmpty(gridLookUpEditDepartment.Text))
            {
                Ultils.GridLookUpEditControlNotNull(gridLookUpEditDepartment, "một Bộ phận");
            }

            else
            {
                var issue = new Issue()
                {
                    IssueID   = lblReceiptID.Text,
                    IssueDate = DateTime.Now,
                    Total     = Convert.ToInt32(_total),
                    //Price = Convert.ToInt32(_price),
                    Active          = true,
                    CreatedBy       = Program.CurrentUser.Username,
                    EmployeeCode    = txtEmployeeCode.Text,
                    EmployeeRequest = txtEmployeeName.Text,
                    DepartmentID    = gridLookUpEditDepartment.EditValue.ToString()
                };

                try
                {
                    _issueService.Add(issue);
                    _logService.InsertLog(Program.CurrentUser.Username, "Xuất kho", this.Text);
                    foreach (Cart cart in _order.Carts)
                    {
                        InsertIssueDetails(lblReceiptID.Text, cart.ProductId, cart.Quantity, cart.Price, cart.Total, gridLookUpEditDepartment.EditValue.ToString());
                        _inventoryService.InsertOrUpdateIssue(cart.ProductId, cart.Quantity, lblReceiptID.Text);
                    }
                    if (_order.Carts.Count > 0)
                    {
                        _order.Carts.Clear();
                    }

                    MessageBoxHelper.ShowMessageBoxInfo("Nhập hàng thành công!");
                    gridControlStockImport.DataSource = null;
                    ResetProductControls();
                    EnabledButtonSaveAndPrint(false);
                    // Tạo tiếp ID
                    lblReceiptID.Text = _issueService.NextId();
                }
                catch (SqlException ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowMessageBoxError(ex.Message);
                }
            }
        }
Exemplo n.º 5
0
        private issue IssueBook()
        {
            if (StringUtil.NotNullAndNotBlank(Request.Form["student_id"]) &&
                StringUtil.NotNullAndNotBlank(Request.Form["book_recs"]))
            {
                issueService      = new IssueService();
                studentService    = new StudentService();
                bookRecordService = new Book_recordService();
                BookIssueService  = new book_issueService();

                string  StudentId = Request.Form["student_id"];
                student Student   = (student)studentService.GetById(StudentId);
                if (Student == null)
                {
                    return(null);
                }

                string IssueID = StringUtil.GenerateRandomNumber(9);
                issue  Issue   = new issue();
                Issue.user_id        = User.id;
                Issue.id             = IssueID;
                Issue.type           = "issue";
                Issue.date           = DateTime.Now;
                Issue.student_id     = Student.id;
                Issue.addtional_info = "test";

                string[] BookRecIds = Request.Form["book_recs"].Split(';');

                if (BookRecIds.Length < 1)
                {
                    return(null);
                }

                if (null == issueService.Add(Issue))
                {
                    return(null);
                }

                List <book_issue> BookIssues = new List <book_issue>();
                foreach (string Id in BookRecIds)
                {
                    book_record BR = (book_record)bookRecordService.GetById(Id);
                    if (BR == null || BR.available == 0)
                    {
                        continue;
                    }
                    book_issue BookIssue = new book_issue();
                    BookIssue.id             = StringUtil.GenerateRandomChar(10);
                    BookIssue.issue_id       = IssueID;
                    BookIssue.book_record_id = Id;
                    BookIssue.qty            = 1;
                    BookIssues.Add(BookIssue);
                    BookIssueService.Add(BookIssue);

                    BR.available = 0;
                    bookRecordService.Update(BR);
                }
                Issue.book_issue = BookIssues;

                return(Issue);
            }
            return(null);
        }