Ejemplo n.º 1
0
        public IHttpActionResult DelRelation_UseGroup(Guid UseGroupID)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            try
            {
                Relation_UseGroup rrelation_UseGroupModel = new Relation_UseGroup();
                rrelation_UseGroupModel.UseGroupID = UseGroupID;
                if (transRelation_UseGroup.DelUseGroup_User(UseGroupID))//删除用户组用户信息
                {
                    int i = useGroupAdapter.Remove(rrelation_UseGroupModel);
                    if (i > 0)
                    {
                        isSucceed.IsSucceed    = true;
                        isSucceed.ErrorMessage = "删除成功";
                    }
                    else
                    {
                        isSucceed.IsSucceed    = false;
                        isSucceed.ErrorMessage = "删除失败";
                    }
                }
                else
                {
                    isSucceed.IsSucceed    = false;
                    isSucceed.ErrorMessage = "删除用户组用户失败";
                }
            }
            catch (Exception ex)
            {
                isSucceed.IsSucceed    = false;
                isSucceed.ErrorMessage = "删除失败:" + ex.ToString();
            }
            return(Json(isSucceed));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> AddRrelation_UseGroup([FromBody] Relation_UseGroup model)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            if (!model.SponsorID.HasValue)
            {
                isSucceed.IsSucceed    = false;
                isSucceed.ErrorMessage = "邀请人信息有误!";
                return(Json(isSucceed));
            }
            else if (string.IsNullOrEmpty(model.UseGroupName))
            {
                isSucceed.IsSucceed    = false;
                isSucceed.ErrorMessage = "组名称不能为空!";
                return(Json(isSucceed));
            }
            return(Json(await transRelation_UseGroup.AddOrUpdateRelation_UseGroup(model)));
        }
Ejemplo n.º 3
0
        public IHttpActionResult AddOrUpdateRrelation_UseGroup([FromBody] Relation_UseGroup model)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            try
            {
                Relation_UseGroup rrelation_UseGroupModel = useGroupAdapter.GetAll().Where(w => w.UseGroupID == model.UseGroupID).FirstOrDefault();
                if (rrelation_UseGroupModel == null)//添加
                {
                    rrelation_UseGroupModel            = new Relation_UseGroup();
                    rrelation_UseGroupModel.UseGroupID = Guid.NewGuid();
                    rrelation_UseGroupModel.CreateTime = DateTime.Now;
                }
                rrelation_UseGroupModel.UseGroupName = model.UseGroupName;
                rrelation_UseGroupModel.SponsorID    = model.SponsorID;
                rrelation_UseGroupModel.Describe     = model.Describe;
                rrelation_UseGroupModel.GroupType    = model.GroupType;
                rrelation_UseGroupModel.Sort         = model.Sort;

                int i = useGroupAdapter.AddOrUpdate(rrelation_UseGroupModel);
                if (i > 0)
                {
                    isSucceed.IsSucceed = true;
                }
                else
                {
                    isSucceed.IsSucceed    = false;
                    isSucceed.ErrorMessage = "无操作记录!";
                }
                return(Json(isSucceed));
            }
            catch (Exception ex)
            {
                isSucceed.IsSucceed    = false;
                isSucceed.ErrorMessage = ex.Message + "\r\n" + ex.StackTrace;
                return(Json(isSucceed));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加用户组信息  邀请人信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <WebModelIsSucceed> AddOrUpdateRelation_UseGroup(Relation_UseGroup model)
        {
            WebModelIsSucceed isSucceed = new WebModelIsSucceed();

            using (OperationManagerDbContext db = new OperationManagerDbContext())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    List <Relation_UseGroup_User> list = new List <Relation_UseGroup_User>();
                    try
                    {
                        Relation_UseGroup rrelation_UseGroupModel = null; // new Relation_UseGroup();// useGroupAdapter.GetAll().Where(w => w.UseGroupID == model.UseGroupID).FirstOrDefault();
                        if (rrelation_UseGroupModel == null)              //添加
                        {
                            rrelation_UseGroupModel            = new Relation_UseGroup();
                            rrelation_UseGroupModel.UseGroupID = Guid.NewGuid();
                            rrelation_UseGroupModel.CreateTime = DateTime.Now;
                        }
                        rrelation_UseGroupModel.UseGroupName = model.UseGroupName;
                        rrelation_UseGroupModel.SponsorID    = model.SponsorID;
                        rrelation_UseGroupModel.Describe     = model.Describe;
                        rrelation_UseGroupModel.GroupType    = model.GroupType;
                        rrelation_UseGroupModel.Sort         = model.Sort;
                        if (model.Relation_UseGroup_User != null)//邀请人信息
                        {
                            foreach (var Relation_UseGroup_User in model.Relation_UseGroup_User)
                            {
                                Relation_UseGroup_User relation_UseGroup_User = new Relation_UseGroup_User();
                                relation_UseGroup_User.UUID           = Guid.NewGuid();
                                relation_UseGroup_User.UseGroupID     = rrelation_UseGroupModel.UseGroupID;
                                relation_UseGroup_User.SysUserID      = Relation_UseGroup_User.SysUserID;
                                relation_UseGroup_User.InvitationTime = DateTime.Now;
                                relation_UseGroup_User.Join           = 0;
                                relation_UseGroup_User.sort           = Relation_UseGroup_User.sort == null ? 0: Relation_UseGroup_User.sort;
                                list.Add(relation_UseGroup_User);
                            }
                            //加入创建组人信息 创建人自己
                            Relation_UseGroup_User relation_UseGroup_UserAdmin = new Relation_UseGroup_User();
                            relation_UseGroup_UserAdmin.UUID           = Guid.NewGuid();
                            relation_UseGroup_UserAdmin.UseGroupID     = rrelation_UseGroupModel.UseGroupID;
                            relation_UseGroup_UserAdmin.SysUserID      = model.SponsorID;
                            relation_UseGroup_UserAdmin.InvitationTime = DateTime.Now;
                            relation_UseGroup_UserAdmin.Join           = 1;
                            relation_UseGroup_UserAdmin.sort           = 0;
                            list.Add(relation_UseGroup_UserAdmin);
                        }

                        db.Relation_UseGroup.AddOrUpdate(rrelation_UseGroupModel);
                        if (list.Count > 0)
                        {
                            db.Relation_UseGroup_User.AddOrUpdate(list.ToArray());
                        }

                        isSucceed.IsSucceed = await db.SaveChangesAsync() > 0 ? true : false;

                        dbContextTransaction.Commit();
                        return(isSucceed);
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        isSucceed.IsSucceed    = false;
                        isSucceed.ErrorMessage = ex.Message + "\r\n" + ex.StackTrace;
                        return(isSucceed);
                    }
                }
            }
        }