예제 #1
0
        public PlotChartX Update(PlotChartX entity)
        {
            Contract.Requires(entity != null, "provided entity can not be null");
            Contract.Requires(entity.Id >= 0, "provided entity must have a permanent ID");

            Contract.Ensures(Contract.Result <PlotChartX>() != null && Contract.Result <PlotChartX>().Id >= 0, "No entity is persisted!");

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <PlotChartX> repo = uow.GetRepository <PlotChartX>();
                repo.Put(entity); // Merge is required here!!!!
                uow.Commit();
            }
            return(entity);
        }
예제 #2
0
        public PlotChartX Create(string plotId, string plotType, string latitude, string longitude, string coordinate, string coordinateType, string geometryType, string geometryText, long logedId, String action, DateTime dateTime, string referencePoint = "")
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(plotId));
            Contract.Requires(!string.IsNullOrWhiteSpace(plotType) != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(latitude) != null);
            Contract.Requires(!string.IsNullOrWhiteSpace(longitude) != null);
            Contract.Ensures(Contract.Result <PlotChartX>() != null && Contract.Result <PlotChartX>().Id >= 0);

            //PartyStatus initialStatus = new PartyStatus();
            //initialStatus.Timestamp = DateTime.UtcNow;
            //initialStatus.Description = "Created";
            //initialStatus.StatusType = statusType;

            PlotChartX entity = new PlotChartX()
            {
                PlotId         = plotId,
                Latitude       = latitude,
                Longitude      = longitude,
                GeometryType   = geometryType,
                GeometryText   = geometryText,
                Coordinate     = coordinate,
                CoordinateType = coordinateType,
                Status         = 1,
                VersionNo      = 1,
                Extra          = null,
                PlotType       = "",
                LogedId        = logedId,
                LogTime        = dateTime,
                Action         = action,
                ReferencePoint = referencePoint
                                 //Area = null
            };

            //entity.History.Add(initialStatus);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <PlotChartX> repo = uow.GetRepository <PlotChartX>();
                repo.Put(entity); // must store the status objects too
                uow.Commit();
            }
            return(entity);
        }
예제 #3
0
        public bool Delete(PlotChartX entity)
        {
            Contract.Requires(entity != null);
            Contract.Requires(entity.Id >= 0);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository <PlotChartX> repo = uow.GetRepository <PlotChartX>();

                entity = repo.Reload(entity);


                //delete the entity
                repo.Delete(entity);

                // commit changes
                uow.Commit();
            }
            // if any problem was detected during the commit, an exception will be thrown!
            return(true);
        }