Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="team"></param>
        /// <returns></returns>
        public OperationResult <ModelOrg> Update(ModelOrg org)
        {
            OperationResult <ModelOrg> res;

            try
            {
                var entity = org.ToEntity();

                DataContext.Update(entity);

                DataContext.SaveChanges();

                var model = entity.ToModel();

                res = OperationResult <ModelOrg> .Create(model);

                IncrementUsersVersion(org.Id);
            }
            catch (Exception e)
            {
                res = OperationResult <ModelOrg> .Create(ErrorCode.BadUpdateOrg, e);
            }

            return(res);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="team"></param>
        /// <returns></returns>
        public OperationResult <ModelOrg> Create(ModelOrg org, bool addMembership = true)
        {
            OperationResult <ModelOrg> res;

            try
            {
                var entity = org.ToEntity();

                DataContext.Add(entity);

                DataContext.SaveChanges();

                var model = entity.ToModel();

                org.Id = model.Id;

                if (addMembership)
                {
                    DataContext.OrgMember.Add(new OrgMember(entity.Id, DataContext.ActiveUserId));
                    DataContext.SaveChanges();
                }

                res = OperationResult <ModelOrg> .Create(model);
            }
            catch (Exception e)
            {
                res = OperationResult <ModelOrg> .Create(ErrorCode.BadCreateOrg, e);
            }

            return(res);
        }