示例#1
0
        public void CreateDeliveryNote(DeliveryNote dn)
        {
            //Business Logic Here

            Location site = locationDao.FindLocationAll().Where(b=>b.Id==2).FirstOrDefault();
            deliveryNoteDao.CreateDeliveryNote(dn);
        }
        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");
        }
示例#3
0
        public ActionResult Create(FormCollection collection, string deliveryNoteItemJson)
        {
            IDeliveryNoteService DeliveryNoteSrv = (IDeliveryNoteService)appContext.GetObject("DeliveryNoteSrv");
            INoteLineItemService NoteLineItemSrv=(INoteLineItemService)appContext.GetObject("NoteLineItemSrv");

            var car = collection["CarType"].ToString();
            var CarLicensePlate = collection["CarLicensePlate"].ToString();
            var SenderName = collection["SenderName"].ToString();
            var submittedDntItems = deliveryNoteItemJson == "" ? new List<NoteLineItem>() : JsonConvert.DeserializeObject<IList<NoteLineItem>>(deliveryNoteItemJson);

            //int deliveryNoteId = Convert.ToInt32( collection["DeliveryNoteId"]);
            //int destinationId = Convert.ToInt32(collection["DestinationId"]);

            try
            {
                if (!string.IsNullOrEmpty(collection["DeliveryNoteId"]) && (!string.IsNullOrEmpty(collection["DestinationId"])))
                {
                    foreach(NoteLineItem item in submittedDntItems){
                        int itemId = (int)item.Id;
                       // DeliveryNoteSrv.SetStatusToItem(deliveryNoteId, destinationId);
                    }
                }
                DeliveryNote note = new DeliveryNote();
                note.SenderName = SenderName;
                note.CarType = car;
                note.CarLicensePlate = CarLicensePlate;
                note.Id = 0;

                // TODO: Add insert logic here
                //DeliveryNoteSrv.CreateDeliveryNote(note);
                return View();
            }
            catch
            {
                return View();
            }
        }
示例#4
0
 public void UpdateDeliveryNote(DeliveryNote Note)
 {
     //Business Logic Here
     deliveryNoteDao.UpdateDeliveryNote(Note);
 }
示例#5
0
 public List<DeliveryNote> FindDeliveryNoteByCriteria(DeliveryNote note)
 {
     throw new NotImplementedException();
 }
        public static DeliveryNote SampleData()
        {
            ManeeDataContainer context = new ManeeDataContainer();
                DeliveryNote note = new DeliveryNote();

                note.Code = "DN001";
                note.DeliveryDate = DateTime.Now;
                note.Id = 0;
                note.Destination = new Location();
                note.Destination.Id = context.Locations.FirstOrDefault(b => b.Id == 2).Id;
                note.Origin =new Location() ;
                note.Origin.Id = context.Locations.FirstOrDefault(b=>b.Id==3).Id;

                //note.Destination = context.Locations.FirstOrDefault(b => b.Id == 2);
                //note.Origin = context.Locations.FirstOrDefault(b => b.Id == 3);

                note.SenderCode = "Sender1";
                note.SenderName = "SS";
                note.CarType = "Car";
                note.CarLicensePlate = "a-222";
                return note;
        }