Example #1
0
 public bool DeleteGiftCertificate(GiftCertificate giftCertificate)
 {
     if (giftCertificate == null) return false;
     _unitOfWork.GiftCertificateRepository.Delete(giftCertificate);
     _unitOfWork.Save();
     return true;
 }
Example #2
0
        public ActionResult AddNewDonationPlan(Cats.Models.Hubs.ReceiptAllocationViewModel receiptAllocationViewModel)
        {
            ModelState.Remove("SourceHubID");
            ModelState.Remove("SupplierName");
            ModelState.Remove("PurchaseOrder");



            if (ModelState.IsValid)
            {
                var receiptAllocation = receiptAllocationViewModel.GenerateReceiptAllocation();

                if (receiptAllocationViewModel.GiftCertificateDetailID == 0 || receiptAllocationViewModel.GiftCertificateDetailID == null)
                {
                    var shippingInstruction = _shippingInstructionService.FindBy(t => t.Value == receiptAllocationViewModel.SINumber).FirstOrDefault();
                    var gc = new Cats.Models.GiftCertificate();
                    if (shippingInstruction != null)
                    {
                        gc = _giftCertificateService.FindBySINumber(shippingInstruction.Value);
                    }

                    if (gc != null)
                    {
                        var gcd = gc.GiftCertificateDetails.FirstOrDefault(p => p.CommodityID == receiptAllocationViewModel.CommodityID);
                        if (gcd != null)
                        {
                            receiptAllocation.GiftCertificateDetailID = gcd.GiftCertificateDetailID;
                        }
                    }
                    else
                    {
                        receiptAllocation.GiftCertificateDetailID = null;
                    }
                }



                receiptAllocation.HubID             = receiptAllocationViewModel.HubID;
                receiptAllocation.CommoditySourceID = Cats.Models.Hubs.CommoditySource.Constants.DONATION;

                receiptAllocation.ReceiptAllocationID = Guid.NewGuid();
                _receiptAllocationService.AddReceiptAllocation(receiptAllocation);

                return(RedirectToAction("Index"));
            }


            return(RedirectToAction("Index"));
        }
        public static GiftCertificate BindGiftCertificate(GiftCertificate giftCertificate, GiftCertificateViewModel giftCertificateViewModel)
        {
            giftCertificate.GiftCertificateID = giftCertificateViewModel.GiftCertificateID;
            giftCertificate.GiftDate = giftCertificateViewModel.GiftDate;
               // giftCertificate.SINumber = giftCertificateViewModel.SINumber;
            giftCertificate.DonorID = giftCertificateViewModel.DonorID;
            giftCertificate.ReferenceNo = giftCertificateViewModel.ReferenceNo;
            giftCertificate.Vessel = giftCertificateViewModel.Vessel;
            giftCertificate.ETA = giftCertificateViewModel.ETA;
            giftCertificate.IsPrinted = giftCertificateViewModel.IsPrinted;
            giftCertificate.DModeOfTransport = giftCertificateViewModel.DModeOfTransport;
            giftCertificate.ProgramID = giftCertificateViewModel.ProgramID;
            giftCertificate.PortName = giftCertificateViewModel.PortName;
            giftCertificate.DeclarationNumber = giftCertificateViewModel.DeclarationNumber;

            return giftCertificate;
        }
Example #4
0
        public JsonResult Load(string id)
        {
            try
            {
                Cats.Models.GiftCertificate giftCertificate = null;
                giftCertificate = _giftCertificateService.GetAllGiftCertificate().FirstOrDefault(d => d.ShippingInstruction.Value == id);

                return(giftCertificate != null?Json(new { donorId = giftCertificate.Donor.Name,
                                                          programId = giftCertificate.Program.Name,
                                                          eta = giftCertificate.ETA,
                                                          quantity = giftCertificate.GiftCertificateDetails[0].WeightInMT,
                                                          comodity = giftCertificate.GiftCertificateDetails[0].Commodity.Name,
                                                          commodityType = giftCertificate.GiftCertificateDetails[0].Commodity.CommodityType.Name }, JsonRequestBehavior.AllowGet) : null);
            }
            catch (Exception exception)
            {
                var log = new Logger();
                log.LogAllErrorsMesseges(exception, _log);
                ModelState.AddModelError("Errors", @"Gift certificate detail information is not available.");
                return(null);
            }
        }
Example #5
0
 public bool EditGiftCertificate(GiftCertificate giftCertificate)
 {
     _unitOfWork.GiftCertificateRepository.Edit(giftCertificate);
     _unitOfWork.Save();
     return true;
 }
Example #6
0
        public ActionResult AddNewDonationPlan(Cats.Models.Hubs.ReceiptAllocationViewModel receiptAllocationViewModel)
        {
            ModelState.Remove("SourceHubID");
            ModelState.Remove("SupplierName");
            ModelState.Remove("PurchaseOrder");

            if (ModelState.IsValid)
            {
                var receiptAllocation = receiptAllocationViewModel.GenerateReceiptAllocation();

                if (receiptAllocationViewModel.GiftCertificateDetailID == 0 || receiptAllocationViewModel.GiftCertificateDetailID == null)
                {
                    var shippingInstruction = _shippingInstructionService.FindBy(t => t.Value == receiptAllocationViewModel.SINumber).FirstOrDefault();
                    var gc = new Cats.Models.GiftCertificate();
                    if (shippingInstruction != null)
                        gc = _giftCertificateService.FindBySINumber(shippingInstruction.Value);

                    if (gc != null)
                    {
                        var gcd = gc.GiftCertificateDetails.FirstOrDefault(p => p.CommodityID == receiptAllocationViewModel.CommodityID);
                        if (gcd != null)
                        {
                            receiptAllocation.GiftCertificateDetailID = gcd.GiftCertificateDetailID;
                        }
                    }
                    else
                    {
                        receiptAllocation.GiftCertificateDetailID = null;
                    }
                }

                receiptAllocation.HubID = receiptAllocationViewModel.HubID;
                receiptAllocation.CommoditySourceID = Cats.Models.Hubs.CommoditySource.Constants.DONATION;

                receiptAllocation.ReceiptAllocationID = Guid.NewGuid();
                _receiptAllocationService.AddReceiptAllocation(receiptAllocation);

                return RedirectToAction("Index");

            }

            return RedirectToAction("Index");
        }
        public static GiftCertificateViewModel BindGiftCertificateViewModel(GiftCertificate giftCertificateModel, string userPrefrence, bool bindWithDetail = false)
        {
            var giftCertificateViewModel = new GiftCertificateViewModel();

            giftCertificateViewModel.GiftCertificateID = giftCertificateModel.GiftCertificateID;
            giftCertificateViewModel.GiftDate = giftCertificateModel.GiftDate;
            giftCertificateViewModel.DonorID = giftCertificateModel.DonorID;
            giftCertificateViewModel.SINumber = giftCertificateModel.ShippingInstruction.Value;
            giftCertificateViewModel.ReferenceNo = giftCertificateModel.ReferenceNo;
            giftCertificateViewModel.Vessel = giftCertificateModel.Vessel;
            giftCertificateViewModel.ETA = giftCertificateModel.ETA;
            giftCertificateViewModel.ProgramID = giftCertificateModel.ProgramID;
            giftCertificateViewModel.PortName = giftCertificateModel.PortName;
            giftCertificateViewModel.DModeOfTransport = giftCertificateModel.DModeOfTransport;
            giftCertificateViewModel.Donor = giftCertificateModel.Donor.Name;
            giftCertificateViewModel.StatusID = giftCertificateModel.StatusID;
            giftCertificateViewModel.DeclarationNumber = giftCertificateModel.DeclarationNumber;
            giftCertificateViewModel.GiftDatePref=giftCertificateModel.GiftDate.ToCTSPreferedDateFormat(userPrefrence);

            var giftCertificateDetail = giftCertificateModel.GiftCertificateDetails.FirstOrDefault();
            if (giftCertificateDetail != null)
                giftCertificateViewModel.CommodityTypeID = giftCertificateDetail.Commodity.CommodityTypeID;
            else
                giftCertificateViewModel.CommodityTypeID = 1;//by default 'food'
            if (bindWithDetail)
            {
                giftCertificateViewModel.GiftCertificateDetails =
                     BindListOfGiftCertificateDetailsViewModel(
                         giftCertificateModel.GiftCertificateDetails.ToList(),userPrefrence);
            }

            return giftCertificateViewModel;
        }