Пример #1
0
        public void SetNoteLineItemToNote_CorrectItemAndNote()
        {
            PrepareNoteLineItemData.DeleteAllSampleData();
            PrepareDeliveryNoteData.DeleteAllSampleData();

            DeliveryNote note = new DeliveryNote();
            note = PrepareDeliveryNoteData.SampleData();
            deliveryNoteDAO.CreateDeliveryNote(note);

            NoteLineItem item = new NoteLineItem();
            item = PrepareNoteLineItemData.Sample();
            noteLineItemDAO.CreateNoteLineItem(item);

            // Method ที่ต้องการ Test---------------

            noteLineItemService.SetNoteLineItemToNote(item.Id, note.Id);

            //------------------------------------------

            ManeeDataContainer context = new ManeeDataContainer();
            NoteLineItem itemInDB = context.NoteLineItems.Where(m => m.ItemCode == item.ItemCode).FirstOrDefault();
            DeliveryNote noteInDB = context.DeliveryNotes.Where(m => m.Code == note.Code).FirstOrDefault();
            int expectedDeliveryNoteId = noteInDB.Id;

            int accualDeliveryNoteId = itemInDB.DeliveryNote.Id;

            //ต้องลบ NoteLinteItem ก่อนเพราะเรื่อง Foreign Key

            PrepareNoteLineItemData.DeleteAllSampleData();
            PrepareDeliveryNoteData.DeleteAllSampleData();

            Assert.AreEqual(expectedDeliveryNoteId, accualDeliveryNoteId, "Failed");
        }
Пример #2
0
        public void UpdateNoteLineItem(NoteLineItem item)
        {
            //NoteLineItem updateItem = context.NoteLineItems.FirstOrDefault(m => m.Id == item.Id);

            context.DeliveryNotes.Attach(item.DeliveryNote);
            //context.Locations.Attach(item.Location);
            //updateItem = item;
            //updateItem.DeliveryNote.Id = item.DeliveryNote.Id;
            //context.DeliveryNotes.Attach(updateItem.DeliveryNote);
            //context.Locations.Attach(updateItem.Location);

            context.SaveChanges();
        }
Пример #3
0
        //
        // GET: /DeliveryNote/Create
        public ActionResult Create()
        {
            int location_Id = 2;
            NoteLineItem itemCriteria = new NoteLineItem();

            ICarService carService = (ICarService)appContext.GetObject("CarSrv");
            IDeliveryNoteService service = (IDeliveryNoteService)appContext.GetObject("DeliveryNoteSrv");
            INoteLineItemService nliService = (INoteLineItemService)appContext.GetObject("NoteLineItemSrv");
            ViewData["cars"] = carService.FindCarAll();

            List<NoteLineItem> n = nliService.FindNoteLineItemByLocation(location_Id);

            ViewData["NoteLineItem"] = nliService.FindNoteLineItemByLocation(location_Id);

            return View();
        }
Пример #4
0
        public static NoteLineItem Sample()
        {
            ILocationDAO locationDAO = (ILocationDAO)DAOFactory.GetDao("LOCATION");
            ManeeDataContainer context = new ManeeDataContainer();

            NoteLineItem item = new NoteLineItem();
            item.Id=0;
            item.ItemCode = "LK-001";
            item.ItemDescription = "steel";

            item.Location = new Location();
            item.Location.Id = context.Locations.FirstOrDefault(m=>m.Id==2).Id;
            item.Quantity=1;
            item.Status = 1;
            item.Unit = "ton";
            return item;
        }
Пример #5
0
 public void CreateNoteLineItem(NoteLineItem item)
 {
     noteLineItemDAO.CreateNoteLineItem(item);
 }