Exemplo n.º 1
0
        private DataRepository dataForSelectedOntogeny(Unit xUnit, Unit yUnit)
        {
            var dataRepository = new DataRepository {
                Name = PKSimConstants.UI.OntogenyFor(_dto.SelectedOntogeny.DisplayName)
            };
            var pma = new BaseGrid(PKSimConstants.UI.PostMenstrualAge, _dimensionRepository.AgeInYears)
            {
                DisplayUnit = xUnit
            };
            var mean = new DataColumn(dataRepository.Name, _dimensionRepository.Fraction, pma)
            {
                DisplayUnit = yUnit
            };
            var std = new DataColumn(PKSimConstants.UI.StandardDeviation, _dimensionRepository.Fraction, pma)
            {
                DisplayUnit = yUnit
            };

            mean.DataInfo.AuxiliaryType = AuxiliaryType.GeometricMeanPop;
            std.AddRelatedColumn(mean);
            dataRepository.Add(mean);
            dataRepository.Add(std);

            var allOntogenies = _ontogenyRepository.AllValuesFor(_dto.SelectedOntogeny, _dto.SelectedContainer.Name).OrderBy(x => x.PostmenstrualAge).ToList();

            pma.Values  = values(allOntogenies, x => x.PostmenstrualAge);
            mean.Values = values(allOntogenies, x => x.OntogenyFactor);
            std.Values  = values(allOntogenies, x => x.Deviation);
            return(dataRepository);
        }
        protected override void Context()
        {
            _editObservedDataTask = A.Fake <IEditObservedDataTask>();
            _view = A.Fake <IDataRepositoryDataView>();
            _dataRepositoryTask = A.Fake <IDataRepositoryExportTask>();
            _commandCollector   = A.Fake <ICommandCollector>();
            sut = new DataRepositoryDataPresenter(_view, _dataRepositoryTask, _editObservedDataTask);
            sut.InitializeWith(_commandCollector);

            //common setup
            _dataRepository = new DataRepository();
            _dataTable      = new DataTable();
            A.CallTo(() => _dataRepositoryTask.ToDataTable(_dataRepository, A <DataColumnExportOptions> ._)).Returns(new[] { _dataTable });

            var col = _dataTable.AddColumn <float>("test");

            col.ExtendedProperties.Add(Constants.DATA_REPOSITORY_COLUMN_ID, "col");
            _baseGrid = new BaseGrid("base", "base", Constants.Dimension.NO_DIMENSION)
            {
                Values = new ArraySegment <float>()
            };
            _dim = A.Fake <IDimension>();
            _col = new DataColumn("col", "col", _dim, _baseGrid)
            {
                Values = new ArraySegment <float>()
            };
            _dataRepository.Add(_baseGrid);
            _dataRepository.Add(_col);
        }
        protected override void Context()
        {
            _oldName        = "oldName";
            _newName        = "newName";
            _timeDimension  = new Dimension(new BaseDimensionRepresentation(), "Time", "min");
            _concDimension  = new Dimension(new BaseDimensionRepresentation(), "Conc", "mg/l");
            _dataRepository = new DataRepository {
                Name = _oldName
            };
            sut       = new RenameObservedDataCommand(_dataRepository, _newName);
            _baseGrid = new BaseGrid("Time", _timeDimension);
            _column   = new DataColumn("Col", _concDimension, _baseGrid);

            var quantityInfo = new QuantityInfo(new[] { _oldName, ObjectTypes.ObservedData, "Organ", "Compartment", "Drug", _column.Name }, QuantityType.Undefined);

            _baseGrid.QuantityInfo = new QuantityInfo(new[] { _oldName, ObjectTypes.ObservedData }, QuantityType.BaseGrid);
            _column.QuantityInfo   = quantityInfo;
            _dataRepository.Add(_baseGrid);
            _dataRepository.Add(_column);
            _executionContext = A.Fake <IOSPSuiteExecutionContext>();

            A.CallTo(() => _executionContext.Project.ObservedDataBy(_dataRepository.Id)).Returns(_dataRepository);
            _dataRepositoryNamer = A.Fake <IDataRepositoryNamer>();
            A.CallTo(() => _executionContext.Resolve <IDataRepositoryNamer>()).Returns(_dataRepositoryNamer);
        }
        protected override void Context()
        {
            _executionContext = A.Fake <IOSPSuiteExecutionContext>();
            _observedData     = new DataRepository();
            _baseGrid         = new BaseGrid("nameBaseGrid", new Dimension(new BaseDimensionRepresentation(), "Time", "min"));
            var column = new DataColumn("columnId", "name1", new Dimension(new BaseDimensionRepresentation(), "Conc", "mg/l"), _baseGrid)
            {
                Values = new ArraySegment <float>()
            };

            _baseGrid.Values = new ArraySegment <float>();
            _observedData.Add(column);
            _observedData.Add(_baseGrid);

            _observedData.InsertValues(1, new Cache <string, float> {
                { "columnId", 1f }
            });
            _observedData.InsertValues(2, new Cache <string, float> {
                { "columnId", 2f }
            });

            _dataRowData = new DataRowData();

            sut = new AddObservedDataRowCommand(_observedData, _dataRowData);
        }
Exemplo n.º 5
0
        protected override void Context()
        {
            _globalPKAnalysisPresenter = A.Fake <IGlobalPKAnalysisPresenter>();
            _concentrationDim          = A.Fake <IDimension>();
            _timeDim         = A.Fake <IDimension>();
            _view            = A.Fake <IIndividualPKAnalysisView>();
            _pkaAnalysisTask = A.Fake <IPKAnalysisTask>();
            _simulation      = A.Fake <IndividualSimulation>();
            _simulations     = new List <Simulation>();
            _simulations.Add(_simulation);
            _exportTask = A.Fake <IPKAnalysisExportTask>();
            _individualPKAnalysisToDTOMapper = A.Fake <IIndividualPKAnalysisToPKAnalysisDTOMapper>();
            _pkParameterRepository           = A.Fake <IPKParameterRepository>();
            ;
            var dataRepository = new DataRepository();

            _baseGrid = new BaseGrid("Base", _timeDim);
            _col1     = new DataColumn {
                DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.Undefined, "mg", DateTime.Now, string.Empty, string.Empty, 5), Dimension = _concentrationDim
            };
            _col2 = new DataColumn {
                Dimension = _concentrationDim, DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.Undefined, "mg", DateTime.Now, string.Empty, string.Empty, 5)
            };
            _col3 = new DataColumn {
                Dimension = _concentrationDim, DataInfo = new DataInfo(ColumnOrigins.Calculation, AuxiliaryType.Undefined, "mg", DateTime.Now, string.Empty, string.Empty, 5)
            };
            dataRepository.Add(_col1);
            dataRepository.Add(_col2);
            _simulation.DataRepository = dataRepository;
            var curve1 = A.Fake <Curve>();

            A.CallTo(() => curve1.yData).Returns(_col1);
            A.CallTo(() => curve1.xData).Returns(_baseGrid);

            var curve2 = A.Fake <Curve>();

            A.CallTo(() => curve2.yData).Returns(_col2);
            A.CallTo(() => curve2.xData).Returns(_baseGrid);

            var curve3 = A.Fake <Curve>();

            A.CallTo(() => curve3.yData).Returns(_col3);
            A.CallTo(() => curve3.xData).Returns(_col1);

            _curves = new List <Curve> {
                curve1, curve2, curve3
            };
            _allPKAnalysis = new List <Tuple <DataColumn, PKAnalysis> >();
            _pkAnalysis1   = createPKAnalysis();
            _pkAnalysis2   = createPKAnalysis();
            _allPKAnalysis.Add(new Tuple <DataColumn, PKAnalysis>(_col1, _pkAnalysis1));
            _allPKAnalysis.Add(new Tuple <DataColumn, PKAnalysis>(_col2, _pkAnalysis2));
            _allGlobalPKParameters = new List <IParameter>();
            A.CallTo(_pkaAnalysisTask).WithReturnType <IEnumerable <Tuple <DataColumn, PKAnalysis> > >().Returns(_allPKAnalysis);
            A.CallTo(_pkaAnalysisTask).WithReturnType <IEnumerable <IParameter> >().Returns(_allGlobalPKParameters);

            _presenterSettingsTask = A.Fake <IPresentationSettingsTask>();
            sut = new IndividualPKAnalysisPresenter(_view, _pkaAnalysisTask, _exportTask, _globalPKAnalysisPresenter,
                                                    _individualPKAnalysisToDTOMapper, _pkParameterRepository, _presenterSettingsTask);
        }
        public void should_not_return_venous_blood_unbound_plasma()
        {
            var dataRepository = new DataRepository("tralalal");

            dataRepository.Add(_venousBloodUnboundPlasma);
            dataRepository.Add(_venousBloodPlasma);
            dataRepository.VenousBloodColumn("Drug").ShouldBeEqualTo(_venousBloodPlasma);
        }
Exemplo n.º 7
0
        protected override void Context()
        {
            base.Context();
            _repository = new DataRepository("id");
            var baseGrid = new BaseGrid("baseGridId", new Dimension(new BaseDimensionRepresentation(), "dimName", "baseUnit"));

            _repository.Add(baseGrid);
            _repository.Add(new DataColumn("column", new Dimension(new BaseDimensionRepresentation(), "dimName", "baseUnit"), baseGrid));
        }
Exemplo n.º 8
0
        protected override void Context()
        {
            base.Context();
            _simulation = A.Fake <IndividualSimulation>();
            var dimension = A.Fake <IDimension>();

            _compound = A.Fake <Compound>();
            A.CallTo(() => _compound.Name).Returns("Drug");
            //new data repository  + columns
            _newDataRepository      = new DataRepository();
            _newBaseGrid            = new BaseGrid("baseGrid1", "baseGrid1", dimension);
            _newBaseGrid.Values     = new float[] { 1, 2, 3, 4 };
            _newColumn              = new DataColumn("col1", "col1", dimension, _newBaseGrid);
            _newColumn.Values       = new float[] { 1, 1, 1, 1 };
            _newColumn.QuantityInfo = new QuantityInfo("sp1", new List <string> {
                "Liver", "Cell", "Drug", "Obs1"
            }, QuantityType.Observer | QuantityType.Drug);
            _newExistingColumn = new DataColumn("col2", "col2", dimension, _newBaseGrid);
            _newExistingColumn.QuantityInfo = new QuantityInfo("sp2", new List <string> {
                "Liver", "Cell", "Drug", "Obs2"
            }, QuantityType.Observer | QuantityType.Metabolite);
            _newExistingColumn.Values = new float[] { 2, 2, 2, 2 };

            _newDataRepository.Add(_newBaseGrid);
            _newDataRepository.Add(_newColumn);
            _newDataRepository.Add(_newExistingColumn);


            //old data repository  + columns
            _oldDataRepository      = new DataRepository();
            _oldBaseGrid            = new BaseGrid("baseGrid2", "baseGrid2", dimension);
            _oldBaseGrid.Values     = new float[] { 1, 2, 3 };
            _oldColumn              = new DataColumn("col3", "col3", dimension, _oldBaseGrid);
            _oldColumn.Values       = new float[] { 3, 3, 3 };
            _oldColumn.QuantityInfo = new QuantityInfo("sp3", new List <string> {
                "Liver", "Cell", "Drug", "Obs3"
            }, QuantityType.Observer | QuantityType.Drug);
            _oldExistingColumn = new DataColumn("col4", "col4", dimension, _oldBaseGrid);
            _oldExistingColumn.QuantityInfo = new QuantityInfo("sp2", new List <string> {
                "Liver", "Cell", "Drug", "Obs2"
            }, QuantityType.Observer | QuantityType.Drug);
            _oldExistingColumn.Values = new float[] { 2, 2, 2 };

            _oldDataRepository.Add(_oldBaseGrid);
            _oldDataRepository.Add(_oldColumn);
            _oldDataRepository.Add(_oldExistingColumn);

            A.CallTo(() => _simulation.HasResults).Returns(true);
            A.CallTo(() => _simulation.DataRepository).Returns(_oldDataRepository);
            A.CallTo(() => _compound.MolWeight).Returns(20);
            A.CallTo(() => _simulation.BuildingBlock <Compound>()).Returns(_compound);
        }
Exemplo n.º 9
0
 protected override void Context()
 {
     base.Context();
     _originalDataRepository = new DataRepository
     {
         Name        = "Rene",
         Description = "The best Repository"
     };
     _originalDataRepository.Add(_col1);
     _originalDataRepository.Add(_baseGrid);
     _originalDataRepository.Add(_col2);
     _originalDataRepository.Add(_relCol);
     _originalDataRepository.Add(_col3);
 }
Exemplo n.º 10
0
        public void GetEntity()
        {
            _sut.Add(new Description
            {
                Template = nameof(GetEntity)
            });

            _unitOfWork.Commit();

            var entity = _sut.Get(x => x.Template == nameof(GetEntity));

            entity.Should().BeAssignableTo <Description>()
            .And.NotBeNull();
        }
Exemplo n.º 11
0
 public void should_remove_the_column_and_related_column_associated_with_the_column()
 {
    var baseGrid = _dataRepository.BaseGrid;
    var column = DomainHelperForSpecs.ConcentrationColumnForObservedData(baseGrid);
    var errorColumn = DomainHelperForSpecs.ConcentrationColumnForObservedData(baseGrid);
    errorColumn.DataInfo.AuxiliaryType = AuxiliaryType.ArithmeticStdDev;
    column.AddRelatedColumn(errorColumn);
    _dataRepository.Add(column);
    //2 from the creation and new columns + error = 4
    _dataRepository.Columns.Count().ShouldBeEqualTo(4);
    sut.RemoveColumn(_dataRepository, column);
    _dataRepository.Columns.Contains(column).ShouldBeFalse();
    _dataRepository.Columns.Contains(errorColumn).ShouldBeFalse();
 }
        public Result <Rating> AddRating([FromBody] Rating newRating)
        {
            var result = new Result <Rating>();

            try
            {
                var photoInfo = GetPhotoInfoFromId(newRating.PhotoId);

                var allowRating =
                    DataRepository.Queryable <Photo>()
                    .Where(p => p.Id == newRating.PhotoId)
                    .Select(p => p.AllowRating)
                    .SingleOrDefault();

                if (!photoInfo.Member.Options.AllowRating || !allowRating)
                {
                    result.Status.Code    = Controller.StatusCode.NotAuthorized;
                    result.Status.Message = ResultMessages.NotAuthorized;
                    return(result);
                }

                if (string.IsNullOrEmpty(newRating.UserAlias))
                {
                    newRating.UserAlias = newRating.UserName;
                }

                var memberid = GetMemberId();
                if (memberid != Constants.NotSetId)
                {
                    newRating.MemberId = memberid;
                }

                result.Data = DataRepository.AddRating(newRating);

                if (photoInfo.Member.Options.DisplayNotifications)
                {
                    var notification = CreateNotification(newRating, photoInfo);
                    DataRepository.Add(notification);
                    NotificationHub.PushNotification(notification);
                }

                if (photoInfo.Member.Options.NotifyByEmailOnRating)
                {
                    SendNotificationEmail(newRating, photoInfo);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("PRIMARY KEY"))
                {
                    result.Status.Code    = Controller.StatusCode.UserHasAlreadyRated;
                    result.Status.Message = ResultMessages.UnhandledException;
                }
                else
                {
                    LogExceptionAndSetResult(ex, result);
                }
            }
            return(result);
        }
Exemplo n.º 13
0
 protected override void Context()
 {
     base.Context();
     _originalRepository = new DataRepository
     {
         Name        = "Rene",
         Description = "The best Repository"
     };
     _originalRepository.Add(_col1);
     _originalRepository.Add(_col2);
     _originalRepository.Add(_relCol);
     _originalRepository.Add(_col3);
     _originalRepository.ExtendedProperties.Add(new ExtendedProperty <int> {
         Name = "Age", Value = 34
     });
 }
Exemplo n.º 14
0
        public static int Save(Province province)
        {
            var a = new Province
            {
                ProvinceNo   = province.ProvinceNo,
                ProvinceName = province.ProvinceName,
                RegionNo     = province.RegionNo,
                IsActive     = province.IsActive,
                modifieddate = province.modifieddate
            };

            using (_d = new DataRepository <Province>())
            {
                if (province.ProvinceNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.ProvinceNo);
        }
Exemplo n.º 15
0
        public static int Save(Distinction distinction)
        {
            var a = new Distinction
            {
                DistinctionNo   = distinction.DistinctionNo,
                PersonnelNo     = distinction.PersonnelNo,
                DistinctionName = distinction.DistinctionName,
                modifieddate    = distinction.modifieddate
            };

            using (_d = new DataRepository <Distinction>())
            {
                if (distinction.DistinctionNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.DistinctionNo);
        }
Exemplo n.º 16
0
        public static int Save(Spous spouse)
        {
            var a = new Spous
            {
                SpouseNo         = spouse.SpouseNo,
                PersonnelNo      = spouse.PersonnelNo,
                SpouseSurName    = spouse.SpouseSurName,
                SpouseFirstName  = spouse.SpouseFirstName,
                SpouseMiddleName = spouse.SpouseMiddleName,
                Occupation       = spouse.Occupation,
                Employer         = spouse.Employer,
                EmployerAddress  = spouse.EmployerAddress,
                TelephoneNo      = spouse.TelephoneNo,
                IsActive         = spouse.IsActive,
                modifieddate     = spouse.modifieddate
            };

            using (_d = new DataRepository <Spous>())
            {
                if (spouse.SpouseNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.SpouseNo);
        }
Exemplo n.º 17
0
        public static int Save(User user)
        {
            var a = new User
            {
                UserNo    = user.UserNo,
                UserName  = user.UserName,
                UserLevel = user.UserLevel,
                Password  = user.Password,
                IsActive  = user.IsActive
            };

            using (_d = new DataRepository <User>())
            {
                if (user.UserNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.UserNo);
        }
Exemplo n.º 18
0
        public static int Save(LeaveAdd leaveAdd)
        {
            var a = new LeaveAdd
            {
                LeaveAddNo         = leaveAdd.LeaveAddNo,
                LeaveAddDate       = leaveAdd.LeaveAddDate,
                LeaveApplicationNo = leaveAdd.LeaveApplicationNo,
                LeaveCreditNo      = leaveAdd.LeaveCreditNo
            };

            using (_d = new DataRepository <LeaveAdd>())
            {
                if (leaveAdd.LeaveAddNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.LeaveAddNo);
        }
Exemplo n.º 19
0
        public static int Save(Leaf leave)
        {
            var a = new Leaf
            {
                LeaveId       = leave.LeaveId,
                EmployeeId    = leave.EmployeeId,
                LeaveNo       = leave.LeaveNo,
                LeaveDateFrom = leave.LeaveDateFrom,
                LeaveDateTo   = leave.LeaveDateTo,
                LeaveNoDays   = leave.LeaveNoDays,
                LeaveTypeId   = leave.LeaveTypeId
            };

            using (_d = new DataRepository <Leaf>())
            {
                if (leave.LeaveId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.LeaveId);
        }
Exemplo n.º 20
0
        public static DataRepository IndividualSimulationDataRepositoryFor(string simulationName)
        {
            var simulationResults = new DataRepository("Results");
            var baseGrid          = new BaseGrid("Time", TimeDimensionForSpecs())
            {
                Values = new[] { 1.0f, 2.0f, 3.0f }
            };

            simulationResults.Add(baseGrid);

            var data = ConcentrationColumnForSimulation(simulationName, baseGrid);

            simulationResults.Add(data);

            return(simulationResults);
        }
Exemplo n.º 21
0
        public static DataRepository ObservedData(string id = "TestData", IDimension timeDimension = null, IDimension concentrationDimension = null, string obsDataColumnName = null)
        {
            var observedData = new DataRepository(id).WithName(id);
            var baseGrid     = new BaseGrid("Time", timeDimension ?? TimeDimensionForSpecs())
            {
                Values = new[] { 1.0f, 2.0f, 3.0f }
            };

            observedData.Add(baseGrid);

            var data = ConcentrationColumnForObservedData(baseGrid, concentrationDimension, obsDataColumnName);

            observedData.Add(data);

            return(observedData);
        }
        public Result <Comment> AddComment([FromBody] Comment newComment)
        {
            var result = new Result <Comment>();

            try
            {
                if (string.IsNullOrEmpty(newComment.Text) || newComment.Text.Length == 1)
                {
                    result.Status.Code = Controller.StatusCode.NoData;
                    return(result);
                }

                var photoInfo = GetPhotoInfoFromId(newComment.PhotoId);

                var allowCommentOnPhoto =
                    DataRepository.Queryable <Photo>()
                    .Where(p => p.Id == newComment.PhotoId)
                    .Select(p => p.AllowCommenting)
                    .SingleOrDefault();

                if (!photoInfo.Member.Options.AllowComments || !allowCommentOnPhoto)
                {
                    result.Status.Code    = Controller.StatusCode.NotAuthorized;
                    result.Status.Message = ResultMessages.NotAuthorized;
                    return(result);
                }

                if (string.IsNullOrEmpty(newComment.UserAlias))
                {
                    newComment.UserAlias = newComment.UserName;
                }
                result.Data = DataRepository.AddComment(newComment);
                var authenticateUser = GetMemberFromAuthenticatedUser();

                if (authenticateUser != null && !photoInfo.Member.Id.Equals(authenticateUser.Id))
                {
                    if (photoInfo.Member.Options.DisplayNotifications)
                    {
                        var nofitication = CreateNotification(newComment, photoInfo);
                        DataRepository.Add(nofitication);
                        NotificationHub.PushNotification(nofitication);
                    }
                    if (photoInfo.Member.Options.NotifyByEmailOnComment)
                    {
                        SendNotificationEmail(newComment, photoInfo);
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                Log.Error(ex);
                result.Status.Code    = Controller.StatusCode.NotValidEntity;
                result.Status.Message = ResultMessages.NotValidEntity;
            }
            catch (Exception ex)
            {
                LogExceptionAndSetResult(ex, result);
            }
            return(result);
        }
Exemplo n.º 23
0
        public static int Save(Holiday holiday)
        {
            var a = new Holiday
            {
                HolidayId     = holiday.HolidayId,
                HolidayDate   = holiday.HolidayDate,
                HolidayActive = holiday.HolidayActive,
                HolidayNote   = holiday.HolidayNote,
                HolidayType   = holiday.HolidayType
            };

            using (_d = new DataRepository <Holiday>())
            {
                if (holiday.HolidayId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.HolidayId);
        }
Exemplo n.º 24
0
        public static int Save(Product product)
        {
            var a = new Product
            {
                ProductId          = product.ProductId,
                ProductCode        = product.ProductCode,
                ProductName        = product.ProductName,
                ProductDescription = product.ProductDescription,
                ProductGenericName = product.ProductGenericName,
                ProductInstruction = product.ProductInstruction,
                ProductAlertCount  = product.ProductAlertCount,
                ProductLotNo       = product.ProductLotNo,
                ProductPicture     = product.ProductPicture,
                ProductQuantities  = product.ProductQuantities,
                CategoryId         = product.CategoryId,
                SupplierId         = product.SupplierId,
                DrugTypeId         = product.DrugTypeId
            };

            using (_d = new DataRepository <Product>())
            {
                if (product.ProductId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.ProductId);
        }
Exemplo n.º 25
0
        public static int Save(Customer customer)
        {
            var a = new Customer
            {
                CustomerId             = customer.CustomerId,
                CustomerName           = customer.CustomerName,
                CustomerCardNo         = customer.CustomerCardNo,
                CustomerDateRegistered = customer.CustomerDateRegistered,
                CustomerIsActive       = customer.CustomerIsActive,
                CustomerPlateNo        = customer.CustomerPlateNo,
                CustomerVehicle        = customer.CustomerVehicle,
                CustomerAddress        = customer.CustomerAddress
            };

            using (_d = new DataRepository <Customer>())
            {
                if (customer.CustomerId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.CustomerId);
        }
Exemplo n.º 26
0
        public static int Save(Customer customer)
        {
            var a = new Customer
            {
                CustomerId       = customer.CustomerId,
                CustomerName     = customer.CustomerName,
                CustomerAddress  = customer.CustomerAddress,
                CustomerCode     = customer.CustomerCode,
                CustomerContact  = customer.CustomerContact,
                CustomerIsActive = customer.CustomerIsActive
            };

            using (_d = new DataRepository <Customer>())
            {
                if (customer.CustomerId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.CustomerId);
        }
Exemplo n.º 27
0
        public static int Save(Degree degree)
        {
            var a = new Degree
            {
                DegreeNo        = degree.DegreeNo,
                DegreeName      = degree.DegreeName,
                DegreeShortName = degree.DegreeShortName,
                IsActive        = degree.IsActive,
                modifieddate    = degree.modifieddate
            };

            using (_d = new DataRepository <Degree>())
            {
                if (degree.DegreeNo > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.DegreeNo);
        }
Exemplo n.º 28
0
        protected override void Context()
        {
            base.Context();
            _repository1 = new DataRepository().WithName("REP3");
            _repository2 = new DataRepository().WithName("REP4");

            _template.Curves.Add(new CurveTemplate
            {
                Name  = "Curve1",
                xData = { QuantityType = QuantityType.BaseGrid },
                yData = { QuantityType = _drugColumn.QuantityInfo.Type, Path = _drugTemplatePathArray.ToPathString(), RepositoryName = "REP1" }
            });

            _template.Curves.Add(new CurveTemplate
            {
                Name  = "Curve2",
                xData = { QuantityType = QuantityType.BaseGrid },
                yData = { QuantityType = _drugColumn.QuantityInfo.Type, Path = _drugTemplatePathArray.ToPathString(), RepositoryName = "REP2" }
            });

            _repository1.Add(_drugColumn);

            _drugColumn2 = new DataColumn("Drug", _concentrationDimension, new BaseGrid("BaseGrid", _timeDimension))
            {
                QuantityInfo = _drugColumn.QuantityInfo,
                DataInfo     = _drugColumn.DataInfo
            };

            _repository2.Add(_drugColumn2);
            _dataColumns.Add(_drugColumn2);
        }
Exemplo n.º 29
0
        public static int Save(Supplier supplier)
        {
            var a = new Supplier
            {
                SupplierId       = supplier.SupplierId,
                SupplierName     = supplier.SupplierName,
                SupplierAddress  = supplier.SupplierAddress,
                SupplierCode     = supplier.SupplierCode,
                SupplierContact  = supplier.SupplierContact,
                SupplierIsActive = supplier.SupplierIsActive
            };

            using (_d = new DataRepository <Supplier>())
            {
                if (supplier.SupplierId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.SupplierId);
        }
Exemplo n.º 30
0
        public static int Save(Transaction transaction)
        {
            var a = new Transaction
            {
                TransactionId       = transaction.TransactionId,
                TransactionDate     = transaction.TransactionDate,
                TransactionAmount   = transaction.TransactionAmount,
                TransactionPrice    = transaction.TransactionPrice,
                TransactionQnty     = transaction.TransactionQnty,
                TransactionIsActive = transaction.TransactionIsActive,
                UserId            = transaction.UserId,
                TransactionTypeId = transaction.TransactionTypeId,
                GuestId           = transaction.GuestId
            };

            using (_d = new DataRepository <Transaction>())
            {
                if (transaction.TransactionId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.TransactionId);
        }