Ejemplo n.º 1
0
        // [Audit]
        public ActionResult DeliveryWithBarcode()
        {
            BackgroundJobHelper.EnqueueUpdateLastInventoryQuantity4CacheDrugs(null);
            var service    = IoC.Container.Resolve <IDeliveryNoteService>();
            var noteNumber = service.GetNewDeliveryNoteNumber(WebSessionManager.Instance.CurrentDrugStoreCode);
            var dsSession  = (DrugStoreSession)WebSessionManager.Instance.CommonSessionData;
            var allowToChangeTotalAmount = dsSession.Settings.AllowToChangeTotalAmount;
            var model = new
            {
                AllowToChangeTotalAmount = allowToChangeTotalAmount,
                NoteNumber = noteNumber
            };

            ViewBag.ViewModel = JsonConvert.SerializeObject(model);

            return(View("~/Areas/Production/Views/Delivery/DeliveryNoteWithBarcode.cshtml"));
        }
Ejemplo n.º 2
0
        // [Audit]
        public JsonResult SaveDeliveryNote(List <DrugDeliveryItem> deliveryItems, double paymentAmount, int noteNumber,
                                           DateTime?noteDate, int?customerId, int?doctorId, string description)
        {
            IResponseData <int> response = new ResponseData <int>();

            try
            {
                var service = IoC.Container.Resolve <IDeliveryNoteService>();
                var data    = service.SaveDeliveryNote(WebSessionManager.Instance.CurrentDrugStoreCode, WebSessionManager.Instance.CurrentUserId,
                                                       deliveryItems, paymentAmount, noteNumber, noteDate, customerId, doctorId, description);
                response.SetData(data);

                var drugIds = deliveryItems.Select(i => i.DrugId).Distinct().ToArray();
                BackgroundJobHelper.EnqueueUpdateLastInventoryQuantity4CacheDrugs(drugIds);
                BackgroundJobHelper.EnqueueUpdateExtraInfo4DeliveryNotes(data);
            }
            catch (ValidationException ex)
            {
                response.SetErrors(ex.Errors);
                response.SetStatus(HttpStatusCode.PreconditionFailed);
            }

            return(Json(response));
        }