Exemplo n.º 1
0
        public int AddUpdate(ManageAdvertisementModel objectModel)
        {
            tblAdvertisement tblAdvertisementDb = new tblAdvertisement();

            tblAdvertisementDb.AdvertisementId = objectModel.AdvertisementId;
            tblAdvertisementDb.RedirectionUrl  = objectModel.RedirectionUrl;
            tblAdvertisementDb.DisplayOrder    = objectModel.DisplayOrder;
            tblAdvertisementDb.Status          = objectModel.Status;
            tblAdvertisementDb.ImageFile       = objectModel.ImageFile;
            tblAdvertisementDb.ActualImageFile = objectModel.ActualImageFile;

            if (objectModel.AdvertisementId > 0)
            {
                tblAdvertisementDb.ModifiedBy     = AdminSessionData.AdminUserId;
                tblAdvertisementDb.ModifiedOn     = DateTime.Now;
                tblAdvertisementDb.ModifiedFromIP = HttpContext.Current.Request.UserHostAddress;

                context.tblAdvertisements.Attach(tblAdvertisementDb);
                context.Entry(tblAdvertisementDb).Property(x => x.RedirectionUrl).IsModified  = true;
                context.Entry(tblAdvertisementDb).Property(x => x.DisplayOrder).IsModified    = true;
                context.Entry(tblAdvertisementDb).Property(x => x.ImageFile).IsModified       = true;
                context.Entry(tblAdvertisementDb).Property(x => x.ActualImageFile).IsModified = true;
                context.Entry(tblAdvertisementDb).Property(x => x.Status).IsModified          = true;
                context.Entry(tblAdvertisementDb).Property(x => x.ModifiedBy).IsModified      = true;
                context.Entry(tblAdvertisementDb).Property(x => x.ModifiedOn).IsModified      = true;
                context.Entry(tblAdvertisementDb).Property(x => x.ModifiedFromIP).IsModified  = true;
            }
            else
            {
                tblAdvertisementDb.CreatedBy     = AdminSessionData.AdminUserId;
                tblAdvertisementDb.CreatedOn     = DateTime.Now;
                tblAdvertisementDb.CreatedFromIp = HttpContext.Current.Request.UserHostAddress;
                context.tblAdvertisements.Add(tblAdvertisementDb);
            }

            int count = context.SaveChanges();

            if (count == 1)
            {
                count = 0;
            }
            else
            {
                count = -1;
            }

            return(count);
        }
Exemplo n.º 2
0
        public int ActDeact(ManageAdvertisementModel objectModel)
        {
            tblAdvertisement tblAdvertisementDb = new tblAdvertisement();

            tblAdvertisementDb.AdvertisementId = objectModel.AdvertisementId;
            tblAdvertisementDb.Status          = objectModel.Status;

            context.tblAdvertisements.Attach(tblAdvertisementDb);
            context.Entry(tblAdvertisementDb).Property(x => x.Status).IsModified = true;

            int count = context.SaveChanges();

            if (count == 1)
            {
                count = 0;
            }
            else
            {
                count = -1;
            }

            return(count);
        }