Пример #1
0
        /// <summary>
        /// Gets the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public Domain.DmvCalculation Get(int id)
        {
            DmvCalculation dmvCalculationDb = null;

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Include("MobileDeCar").Where(c => c.IsDeleted == false && c.Id == id).FirstOrDefault();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }
Пример #2
0
        /// <summary>
        /// Saves the specified DMV calculation.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public async Task <Domain.DmvCalculation> Save(Domain.DmvCalculation dmvCalculation)
        {
            DmvCalculation dmvCalculationDb = Mapper.Map <DmvCalculation>(dmvCalculation);

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Add(dmvCalculationDb);

                await db.SaveChangesAsync();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }
Пример #3
0
        /// <summary>
        /// Updates the specified DMV calculation.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public async Task <Domain.DmvCalculation> Update(Domain.DmvCalculation dmvCalculation)
        {
            DmvCalculation dmvCalculationDb = Mapper.Map <DmvCalculation>(dmvCalculation);

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Attach(dmvCalculationDb);

                DbEntityEntry <DmvCalculation> entry = db.Entry(dmvCalculationDb);

                entry.State = EntityState.Modified;
                //entry.Property(e => e.MobileDeCarId).IsModified = true;

                await db.SaveChangesAsync();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }