public async Task UpdateASTransactionProductHistory(ASTransactionProductHistory objADTransactionProductHistory)
 {
     try
     {
         _Context.Entry(objADTransactionProductHistory).State = EntityState.Modified;
         await _Context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task InsertASTransactionProductHistory(ASTransactionProductHistory objADTransactionProductHistory)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    _Context.ASTransactionProductHistorys.Add(objADTransactionProductHistory);
                    await _Context.SaveChangesAsync();

                    ASMasterProductChild objASMasterProductChild = _Context.ASMasterProductChilds.Find(objADTransactionProductHistory.MasterProductChildId);
                    objASMasterProductChild.WarrantyExpiryDate = objADTransactionProductHistory.SubscriptionExpiryDate;

                    _Context.Entry(objASMasterProductChild).State = EntityState.Modified;
                    await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
            }
        }
コード例 #3
0
        public async Task <ActionResult <TransactionProductHistoryResult> > PostASTransactionProductHistory(ASTransactionProductHistory objADTransactionProductHistory)
        {
            try
            {
                await _ITransactionProductHistoryInterface.InsertASTransactionProductHistory(objADTransactionProductHistory);

                return(CreatedAtAction("GetASTransactionProductHistory", new { id = objADTransactionProductHistory.TransactionProductHistoryId }, objADTransactionProductHistory));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #4
0
        public async Task <ActionResult <TransactionProductHistoryResult> > PutASTransactionProductHistory(long id, ASTransactionProductHistory objADTransactionProductHistory)
        {
            if (id != objADTransactionProductHistory.TransactionProductHistoryId)
            {
                return(BadRequest());
            }


            try
            {
                await _ITransactionProductHistoryInterface.UpdateASTransactionProductHistory(objADTransactionProductHistory);

                return(_ITransactionProductHistoryInterface.GetASTransactionProductHistoryByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_ITransactionProductHistoryInterface.ASTransactionProductHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task InsertASMasterProduct(ASMasterProductMerge objASMasterProductMerge)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    ASMasterProduct          objASMasterProduct          = objASMasterProductMerge.ASMasterProduct;
                    ASMasterProductChild     objASMasterProductChild     = objASMasterProductMerge.ASMasterProductChild;
                    ASMasterAssetsAssignment objASMasterAssetsAssignment = objASMasterProductMerge.ASMasterAssetsAssignment;

                    _Context.ASMasterProducts.Add(objASMasterProduct);
                    await _Context.SaveChangesAsync();

                    objASMasterProductChild.MasterProductId   = objASMasterProduct.MasterProductId;
                    objASMasterProductChild.ProductChildTitle = objASMasterProduct.ProductTitle;
                    objASMasterProductChild.IsActive          = true;
                    objASMasterProductChild.IsDeadAssets      = false;
                    objASMasterProductChild.IsSaleProduct     = false;
                    _Context.ASMasterProductChilds.Add(objASMasterProductChild);

                    await _Context.SaveChangesAsync();

                    //Insert in TransactionProductHistory
                    ASTransactionProductHistory objASTransactionProductHistory = new ASTransactionProductHistory();
                    if (objASMasterProductChild.MasterEmployeeId != null && objASMasterProductChild.MasterEmployeeId > 0)
                    {
                        objASTransactionProductHistory.MasterProductChildId       = objASMasterProductChild.MasterProductChildId;
                        objASTransactionProductHistory.MasterSubscriptionTypeId   = 1;
                        objASTransactionProductHistory.MasterSubscriptionVendorId = objASMasterProductChild.MasterVendorId;
                        objASTransactionProductHistory.SubscriptionPrice          = objASMasterProductChild.PurchasePrice;
                        objASTransactionProductHistory.SubscriptionDate           = objASMasterProductChild.PurchaseDate;
                        objASTransactionProductHistory.SubscriptionStartDate      = objASMasterProductChild.WarrantyStartDate;
                        objASTransactionProductHistory.SubscriptionExpiryDate     = objASMasterProductChild.WarrantyExpiryDate;

                        _Context.ASTransactionProductHistorys.Add(objASTransactionProductHistory);
                        await _Context.SaveChangesAsync();
                    }


                    if (objASMasterProductChild.MasterEmployeeId != null && objASMasterProductChild.MasterEmployeeId > 0)
                    {
                        //ASMasterAssetsAssignment
                        objASMasterAssetsAssignment.MasterAssetsAssignmentId = 0;
                        objASMasterAssetsAssignment.IsActive             = true;
                        objASMasterAssetsAssignment.AssetsAssignmentDate = objASMasterAssetsAssignment.AssetsAssignmentDate;
                        objASMasterAssetsAssignment.MasterProductChildId = objASMasterProductChild.MasterProductChildId;
                        objASMasterAssetsAssignment.MasterEmployeeId     = objASMasterProductChild.MasterEmployeeId;

                        _Context.ASMasterAssetsAssignments.Add(objASMasterAssetsAssignment);
                        await _Context.SaveChangesAsync();
                    }

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
            }
        }