Exemple #1
0
        public bool Save(PurchaseDTO dto)
        {
            //int result = dataContext.ExecuteCommand(string.Format(DataResource.SQL_SavePurchase, dto.MerchantID, dto.TotalInUSD, dto.TotalInPeso, dto.ExchangeRate, null , dto.Remarks));
            Purchase p = PurchaseDTOConverter.ConvertPurchaseDTO(dto);

            dataContext.Purchases.InsertOnSubmit(p);
            int result = dataContext.GetChangeSet().Inserts.Count;

            dataContext.SubmitChanges();
            return(result > 0);
        }
Exemple #2
0
        public PurchaseDTO GetOnePurchase(int id)
        {
            PurchaseDTO result = null;
            Purchase    data   = dataContext.Purchases.Where(x => x.PurchaseID == id).FirstOrDefault();

            if (data != null)
            {
                result = PurchaseDTOConverter.ConvertPurchase(data);
            }
            return(result);
        }
Exemple #3
0
 public static Purchase ConvertPurchaseDTO(PurchaseDTO p)
 {
     return(new Purchase()
     {
         ExchangeRate = p.ExchangeRate,
         MerchantID = p.MerchantID,
         PurchaseDate = p.PurchaseDate,
         PurchaseID = p.PurchaseID,
         Remarks = p.Remarks,
         TotalInPeso = p.TotalInPeso,
         TotalInUSD = p.TotalInUSD
     });
 }
Exemple #4
0
        public bool Update(int id, PurchaseDTO dto)
        {
            int result = 0;
            //int result = dataContext.ExecuteCommand(string.Format(DataResource.SQL_UpdatePurchase, dto.MerchantID, dto.TotalInUSD, dto.TotalInPeso, dto.ExchangeRate, dto.PurchaseDate, dto.Remarks, id));
            Purchase p = dataContext.Purchases.Where(x => x.PurchaseID == id).FirstOrDefault();

            if (p != null)
            {
                p.MerchantID   = dto.MerchantID;
                p.PurchaseDate = dto.PurchaseDate;
                p.Remarks      = dto.Remarks;
                p.TotalInPeso  = dto.TotalInPeso;
                p.TotalInUSD   = dto.TotalInUSD;
                p.ExchangeRate = dto.ExchangeRate;
            }
            result = dataContext.GetChangeSet().Updates.Count;
            dataContext.SubmitChanges();
            return(result > 0);
        }