Exemplo n.º 1
0
 public static Common.Models.Assets.AssetTag Enable(
     Transaction t,
     Common.Models.Assets.AssetTag model,
     Common.Models.Account.Users enabler)
 {
     return(Enable(model, enabler, t.Connection, false));
 }
Exemplo n.º 2
0
 public static Common.Models.Assets.AssetTag Edit(
     Transaction t,
     Common.Models.Assets.AssetTag model,
     Common.Models.Account.Users modifier)
 {
     return(Edit(model, modifier, t.Connection, false));
 }
Exemplo n.º 3
0
 public static Common.Models.Assets.AssetTag Create(
     Transaction t,
     Common.Models.Assets.AssetTag model,
     Common.Models.Account.Users creator)
 {
     return(Create(model, creator, t.Connection, false));
 }
Exemplo n.º 4
0
        public static Common.Models.Assets.AssetTag Disable(
            Common.Models.Assets.AssetTag model,
            Common.Models.Account.Users disabler,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.DisabledBy = disabler;
            model.Disabled   = DateTime.UtcNow;

            DataHelper.Disable <Common.Models.Assets.AssetTag,
                                DBOs.Assets.AssetTag>("asset_asset_tag", disabler.PId.Value, model.Id, conn, closeConnection);

            return(model);
        }
Exemplo n.º 5
0
        public static Common.Models.Assets.AssetTag Create(
            Common.Models.Assets.AssetTag model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.CreatedBy = model.ModifiedBy = creator;
            model.Created   = model.Modified = DateTime.UtcNow;

            conn = DataHelper.OpenIfNeeded(conn);

            Common.Models.Assets.AssetTag existing = null;
            if (!model.Tag.Id.HasValue)
            {
                Common.Models.Assets.Tag tempTag = Tag.Get(model.Tag.Name.Trim());

                if (tempTag != null)
                {
                    model.Tag = tempTag;
                    existing  = Get(model.Asset.Id.Value, model.Tag.Id.Value);
                }
            }
            else
            {
                existing = Get(model.Asset.Id.Value, model.Tag.Id.Value);
            }

            DBOs.Assets.AssetTag dbo = Mapper.Map <DBOs.Assets.AssetTag>(model);

            //if (existing == null)
            //{
            conn.Execute("INSERT INTO \"asset_asset_tag\" (\"id\", \"asset_id\", \"asset_tag_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                         "VALUES (@Id, @AssetId, @TagId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                         dbo);
            //}
            //else
            //{
            //    model = existing;
            //}

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Exemplo n.º 6
0
        public static Common.Models.Assets.AssetTag Edit(
            Common.Models.Assets.AssetTag model,
            Common.Models.Account.Users modifier,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            model.ModifiedBy = modifier;
            model.Modified   = DateTime.UtcNow;
            DBOs.Assets.AssetTag dbo = Mapper.Map <DBOs.Assets.AssetTag>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("UPDATE \"asset_asset_tag\" SET " +
                         "\"asset_id\"=@AssetId, \"asset_tag_id\"=@TagId, \"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " +
                         "WHERE \"id\"=@Id", dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }