public ReceiptModel Create(FundTrackReceipt model)
 {
     return new ReceiptModel()
     {
         Id = model.Id,
         CheckNumber = model.CheckNumber,
         Comments = model.Comments.Select(x => Create(x)).ToList(),
         ReceiptType = Create(model.ReceiptType),
         ReceivedDate = model.ReceivedDate,
         TotalAmount = model.TotalAmount,
         Servicer = Create(model.Servicer)
     };
 }
        public FundTrackReceipt Create(FundTrackReceipt receipt)
        {
            var newReceipt = new FundTrackReceipt();

            newReceipt.CheckNumber = receipt.CheckNumber;
            newReceipt.TotalAmount = receipt.TotalAmount;
            newReceipt.ReceivedDate = receipt.ReceivedDate;

            newReceipt.ReceiptType = this.GetReceiptTypeById(receipt.ReceiptType.Id);
            newReceipt.Servicer = this.GetSubservicerById(receipt.Servicer.Id);

            _context.FundTrackReceipts
                .Add(newReceipt);

            _context.SaveChanges();

            return newReceipt;
        }
        public static void SeedData(FundTrackContext context)
        {
            int NUMBER_OF_RECEIPTS = 600;
            int MAX_NUMBER_OF_COMMENTS = 20;

            var receiptList = new List<FundTrackReceipt>();

            var cenlarSubServicer = new FundTrackSubservicer
            {
                Name = "Cenlar",
                IsEnabled = true
            };

            var loanCareSubServicer = new FundTrackSubservicer
            {
                Name = "LoanCare",
                IsEnabled = true
            };

            var olegsSubServicer = new FundTrackSubservicer
            {
                Name = "Olegs Subservice",
                IsEnabled = false
            };

            var checkType = new FundTrackReceiptType
            {
                Name = "Check",
                Description =
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae scelerisque tortor. Fusce ac augue in nulla lobortis auctor fringilla id urna. Aenean eleifend metus mi, non fringilla libero tempus ac. Curabitur vitae posuere ligula, ac faucibus ex. Cras placerat est lectus, condimentum dictum est volutpat quis. Proin bibendum vel tortor sit amet lobortis. Curabitur bibendum porttitor erat vel molestie. Morbi auctor cursus nisl et posuere. Donec ac placerat mauris, quis rutrum turpis."
            };

            var wireType = new FundTrackReceiptType
            {
                Name = "Wire",
                Description =
                    "Aenean sed fringilla lectus, vitae placerat mi. Proin non ante interdum, congue metus dignissim, gravida enim. Praesent pulvinar vehicula sodales. In congue hendrerit vestibulum. Sed vitae interdum quam. Maecenas nec quam urna. Nulla sollicitudin, nisi a vulputate luctus, leo neque luctus turpis, quis ultrices mauris dui sit amet diam. Nunc imperdiet quam id lectus convallis, eget condimentum lorem consectetur. Sed dignissim bibendum ultrices. Proin in sem ac dolor vestibulum sodales a nec lacus. Praesent lectus quam, interdum a condimentum accumsan, congue in ante. Phasellus at mi euismod, mollis dui in, ornare nisl."
            };

            context.FundTrackSubservicers.Add(cenlarSubServicer);
            context.FundTrackSubservicers.Add(loanCareSubServicer);
            context.FundTrackSubservicers.Add(olegsSubServicer);
            context.FundTrackReceiptTypes.Add(checkType);
            context.FundTrackReceiptTypes.Add(wireType);

            var random = new Random();

            for (int i = 0; i < NUMBER_OF_RECEIPTS; i++)
            {
                var receipt = new FundTrackReceipt
                {
                    CheckNumber = string.Concat("Paypal:", i.ToString()),
                    ReceivedDate = new DateTime(2005, 1, 1),
                    TotalAmount = random.Next(1000000),
                    ReceiptType = i%2 == 0 ? checkType : wireType,
                    Servicer = i%3 == 0 ? cenlarSubServicer : loanCareSubServicer
                };

                if (i == 10)
                {
                    receipt.Servicer = olegsSubServicer;
                }

                receipt.Comments.AddRange(BuildCommentList(random.Next(MAX_NUMBER_OF_COMMENTS)));

                receiptList.Add(receipt);
            }

            context.FundTrackReceipts
                .AddRange(receiptList);

            context.SaveChanges();
        }
 public FundTrackReceipt UpdateReceipt(FundTrackReceipt updatedReceipt)
 {
     return _repo.Update(updatedReceipt);
 }
 public FundTrackReceipt SaveNewReceipt(FundTrackReceipt receipt)
 {
     return _repo.Create(receipt);
 }
        public FundTrackReceipt Update(FundTrackReceipt updateReceipt)
        {
            FundTrackReceipt receipt = _context.FundTrackReceipts
                .Find(updateReceipt.Id);

            receipt.CheckNumber = updateReceipt.CheckNumber;

            receipt.ReceivedDate = updateReceipt.ReceivedDate;
            receipt.TotalAmount = updateReceipt.TotalAmount;

            receipt.ReceiptType = this.GetReceiptTypeById(updateReceipt.ReceiptType.Id);
            receipt.Servicer = this.GetSubservicerById(updateReceipt.Servicer.Id);

            _context.SaveChanges();
            return receipt;
        }