public ItemRequestFormModel InsertNewItemRequest(InsertItemRequestModel itemRequest)
        {
            ItemRequestForm      newItemRequest = new ItemRequestForm();
            ItemRequestFormModel result         = new ItemRequestFormModel();
            var ticketStatusQuery = _itemRequestFormDataAccess.GetAllTicketStatus();

            int ticketStatusNew = ticketStatusQuery.CodeDetails.Where(x => x.CodeValue.Contains("New"))
                                  .Select(x => x.Id).FirstOrDefault();

            newItemRequest.Title             = itemRequest.Title;
            newItemRequest.StatusCd          = ticketStatusNew;
            newItemRequest.IsActive          = true;
            newItemRequest.Notes             = itemRequest.Notes;
            newItemRequest.FollowupStartDttm = DateTime.UtcNow;
            newItemRequest.CreateUserName    = "******";
            newItemRequest.CreateDttm        = DateTime.UtcNow;
            newItemRequest.UpdateUserName    = "******";
            newItemRequest.UpdateDttm        = DateTime.UtcNow;

            var insertedItem = _itemRequestFormDataAccess.InsertNewItemRequest(newItemRequest);

            result.Id                    = insertedItem.Id;
            result.Title                 = insertedItem.Title;
            result.Notes                 = insertedItem.Notes;
            result.DateCreated           = insertedItem.CreateDttm;
            result.StatusCd              = insertedItem.StatusCd;
            result.RequestFormItems      = new List <ItemList>();
            result.RequestFormQuotations = new List <QuotationList>();

            return(result);
        }
        public ItemRequestFormModel GetItemRequestFormById(int id)
        {
            ItemRequestFormModel result = new ItemRequestFormModel();

            result.RequestFormItems      = new List <ItemList>();
            result.RequestFormQuotations = new List <QuotationList>();
            QuotationList singleQuote  = new QuotationList();
            CodeHeader    ticketStatus = new CodeHeader();
            ItemList      singleItem   = new ItemList();

            var query = _itemRequestFormDataAccess.GetItemRequestFormById(id);

            result.Id           = query.Id;
            result.Title        = query.Title;
            result.DateCreated  = query.CreateDttm;
            result.FollowupDttm = query.FollowupStartDttm.Value;
            result.StatusCd     = query.StatusCd;
            result.Notes        = query.Notes;

            for (int i = 0; i < query.Quotations.Count; i++)
            {
                singleQuote.Id     = query.Quotations.ToList()[i].Id;
                singleQuote.Status = ticketStatus.CodeDetails.Where(x => x.Id == query.Quotations.ToList()[i].StatusCd)
                                     .Select(x => x.CodeValue).FirstOrDefault();
                singleQuote.Notes        = query.Quotations.ToList()[i].Notes;
                singleQuote.Title        = query.Quotations.ToList()[i].Title;
                singleQuote.SupplierName = query.Quotations.ToList()[i].Supplier.SupplierName;

                result.RequestFormQuotations.Add(singleQuote);
                singleQuote = new QuotationList();
            }

            for (int i = 0; i < query.ItemRequestFormMappings.Count; i++)
            {
                singleItem.Id         = query.ItemRequestFormMappings.ToList()[i].ItemID;
                singleItem.ItemName   = query.ItemRequestFormMappings.ToList()[i].Item.ItemName;
                singleItem.StocksLeft = query.ItemRequestFormMappings.ToList()[i].Item.Quantity.Value;
                singleItem.BrandName  = query.ItemRequestFormMappings.ToList()[i].Item.Brand.BrandName;
                singleItem.Notes      = query.ItemRequestFormMappings.ToList()[i].Item.Notes;

                result.RequestFormItems.Add(singleItem);
                singleItem = new ItemList();
            }

            return(result);
        }