public void Map_actions_and_benefits_persistence_to_actions_and_benefits_entity_when_actions_and_benefits_persistance_is_null()
        {
            ActionAndBenefitsPersistance actionAndBenefitsPersistance = null;

            Assert.Throws <ArgumentNullException>(()
                                                  => ActionAndBenefitsMapper.MapActionsAndBenefitsPersistenceToActionsAndBenefitsEntity(actionAndBenefitsPersistance));
        }
        public void Map_actions_and_benefits_persistence_to_actions_and_benefits_entity()
        {
            ActionAndBenefitsPersistance actionAndBenefitsPersistance = this.GetActionAndBenefitsPersistance();

            ActionsAndBenefits action = ActionAndBenefitsMapper.MapActionsAndBenefitsPersistenceToActionsAndBenefitsEntity(actionAndBenefitsPersistance);

            Assert.True(IsEqualeActionsAndBenefitsPersistanceAndActionsAndBenefitsEntity(actionAndBenefitsPersistance, action));
        }
        public bool Delete(Guid id)
        {
            using (DataContext _context = new DataContext())
            {
                ActionAndBenefitsPersistance action = _context.ActionAndBenefits.Find(id);
                if (action == null)
                {
                    return(false);
                }

                _context.ActionAndBenefits.Remove(action);
                _context.SaveChanges();
                return(true);
            }
        }
        public static ActionAndBenefitsPersistance MapActionsAndBenefitsEntityToActionsAndBenefitsPersistance(ActionsAndBenefits actionsAndBenefits)
        {
            if (actionsAndBenefits == null)
            {
                return(null);
            }

            ActionAndBenefitsPersistance retVal = new ActionAndBenefitsPersistance()
            {
                ActionKey    = actionsAndBenefits.IDAction,
                PharmacyName = actionsAndBenefits.PharmacyName,
                ActionName   = actionsAndBenefits.ActionName,
                BeginDate    = actionsAndBenefits.DateRange.StartDateTime,
                EndDate      = actionsAndBenefits.DateRange.EndDateTime,
                OldCost      = actionsAndBenefits.Price.OldPrice,
                NewCost      = actionsAndBenefits.Price.NewPrice,
                IsApproved   = actionsAndBenefits.IsApproved
            };

            return(retVal);
        }
        public static ActionsAndBenefits MapActionsAndBenefitsPersistenceToActionsAndBenefitsEntity(ActionAndBenefitsPersistance actionAndBenefitsPersistance)
        {
            if (actionAndBenefitsPersistance == null)
            {
                throw new ArgumentNullException();
            }

            return(new ActionsAndBenefits(actionAndBenefitsPersistance.ActionKey,
                                          actionAndBenefitsPersistance.PharmacyName,
                                          actionAndBenefitsPersistance.ActionName,
                                          actionAndBenefitsPersistance.BeginDate,
                                          actionAndBenefitsPersistance.EndDate,
                                          actionAndBenefitsPersistance.OldCost,
                                          actionAndBenefitsPersistance.NewCost,
                                          actionAndBenefitsPersistance.IsApproved));
        }
        private bool IsEqualeActionsAndBenefitsPersistanceAndActionsAndBenefitsEntity(ActionAndBenefitsPersistance actionsAndBenefitsPersistence, ActionsAndBenefits actions)
        {
            if (actions.IDAction != actionsAndBenefitsPersistence.ActionKey)
            {
                return(false);
            }
            if (actions.IsApproved != actionsAndBenefitsPersistence.IsApproved)
            {
                return(false);
            }

            if (!actions.ActionName.Equals(actionsAndBenefitsPersistence.ActionName))
            {
                return(false);
            }

            if (actions.DateRange.StartDateTime != actionsAndBenefitsPersistence.BeginDate)
            {
                return(false);
            }
            if (actions.DateRange.EndDateTime != actionsAndBenefitsPersistence.EndDate)
            {
                return(false);
            }

            if (actions.Price.OldPrice != actionsAndBenefitsPersistence.OldCost)
            {
                return(false);
            }

            if (actions.Price.NewPrice != actionsAndBenefitsPersistence.NewCost)
            {
                return(false);
            }

            return(true);
        }