コード例 #1
0
        public AreaLink Save()
        {
            try
            {
                using (rapidInfoEntities context = new rapidInfoEntities())
                {
                    var temp = context.AreaLinks.FirstOrDefault(m => m.AreaId == AreaId && m.IdentityId == IdentityId);
                    context.AddToAreaLinks(this);

                    context.SaveChanges();
                    //Message = "Successfully Updated";
                }
            }
            catch (Exception ex)
            { //Message += ex.Message;
            }
            return(this);
        }
コード例 #2
0
        public AreaLink Delete()
        {
            try
            {
                using (rapidInfoEntities context = new rapidInfoEntities())
                {
                    var temp = context.AreaLinks.FirstOrDefault(m => m.AreaId == AreaId && m.IdentityId == IdentityId);

                    context.AreaLinks.Attach(this);
                    context.AreaLinks.DeleteObject(this);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            return(this);
        }
コード例 #3
0
        public Identity Save()
        {
            try
            {
                using (rapidInfoEntities context = new rapidInfoEntities())
                {
                    var     temp  = context.Identities.FirstOrDefault(m => m.Id == Id);
                    Boolean IsNew = temp == null ? true : false;

                    if (Id == 0)
                    {
                        Id = 1;
                        try { Id = context.Identities.Max(m => m.Id) + 1; }
                        catch { }
                        IsNew = true;
                    }

                    LUDate = DateTime.Now;
                    if (IsNew)
                    {
                        context.AddToIdentities(this);
                    }
                    else
                    {
                        if (temp != null)
                        {
                            context.CreateObjectSet <Identity>().Detach(temp);
                        }

                        context.CreateObjectSet <Identity>().Attach(this);
                        context.ObjectStateManager.ChangeObjectState(this, EntityState.Modified);
                    }
                    context.SaveChanges();
                    //Message = "Successfully Updated";
                }
            }
            catch (Exception ex)
            { //Message += ex.Message;
            }
            return(this);
        }