public bool ObjectExists(FacilitySubscriptionDTO facilitySubscription)
        {
            var objectExists = false;
            var iDbContext   = DbContextUtil.GetDbContextInstance();

            try
            {
                var catRepository = new Repository <FacilitySubscriptionDTO>(iDbContext);
                var catExists     = catRepository.Query()
                                    .Filter(bp => (bp.SubscriptionId == facilitySubscription.SubscriptionId &&
                                                   bp.FacilityId == facilitySubscription.FacilityId) &&
                                            bp.Id != facilitySubscription.Id)
                                    .Get()
                                    .FirstOrDefault();

                if (catExists != null)
                {
                    objectExists = true;
                }
            }
            finally
            {
                iDbContext.Dispose();
            }

            return(objectExists);
        }
        public string InsertOrUpdate(FacilitySubscriptionDTO facilitySubscription)
        {
            try
            {
                var validate = Validate(facilitySubscription);
                if (!string.IsNullOrEmpty(validate))
                {
                    return(validate);
                }

                if (ObjectExists(facilitySubscription))
                {
                    return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine +
                           "With the same Name Exists");
                }

                _facilitySubscriptionRepository.InsertUpdate(facilitySubscription);
                _unitOfWork.Commit();
                return(string.Empty);
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
Ejemplo n.º 3
0
        private void AddNewFacilitySubscription()
        {
            SelectedSubscription = null;
            SelectedFacility     = null;

            SelectedFacilitySubscription = new FacilitySubscriptionDTO();

            SelectedSubscription = Subscriptions.FirstOrDefault();
            SelectedFacility     = Facilities.FirstOrDefault();
        }
        public string Validate(FacilitySubscriptionDTO facilitySubscription)
        {
            if (null == facilitySubscription)
            {
                return(GenericMessages.ObjectIsNull);
            }

            //if (String.IsNullOrEmpty(facilitySubscription.PlateNumber))
            //    return facilitySubscription.PlateNumber + " " + GenericMessages.StringIsNullOrEmpty;

            return(string.Empty);
        }
        public string Disable(FacilitySubscriptionDTO facilitySubscription)
        {
            if (facilitySubscription == null)
            {
                return(GenericMessages.ObjectIsNull);
            }

            string stat;

            try
            {
                _facilitySubscriptionRepository.Update(facilitySubscription);
                _unitOfWork.Commit();
                stat = string.Empty;
            }
            catch (Exception exception)
            {
                stat = exception.Message;
            }
            return(stat);
        }