public static BaseActionResult CreateProfession(Profession obj4create)
        {
            string msg;
            if (obj4create == null)
            {
                msg = string.Format(Intern4jobResources.MSG_CREATE_SUCCESS, Intern4jobResources.STR_PROFESSION) + string.Format(Intern4jobResources.STR_FAIL_RESAON, Intern4jobResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new Intern4jobEntities())
                {
                    var repository = new ProfessionRepository(context);
                    string newId = Guid.NewGuid().ToString();
                    obj4create.Id = newId;
                    repository.Create(obj4create);
                    context.SaveChanges();
                    msg = string.Format(Intern4jobResources.MSG_CREATE_SUCCESS, obj4create.Name);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(Intern4jobResources.MSG_CREATE_FAIL, obj4create.Name) + string.Format(Intern4jobResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
        public static BaseActionResult BulkDeleteProfessionByIds(string idsStr)
        {
            string msg;
            string[] idArr = idsStr.Split(',');
            if (idArr.Length == 0)
            {
                msg = Intern4jobResources.ERR_MSG_NO_RECORD_FOR_ACTION;
                return new BaseActionResult(false, msg);
            }
            try
            {
                List<Profession> list4delete = new List<Profession>();
                foreach (string id in idArr)
                {
                    var obj4delete = GetProfessionById(id);
                    list4delete.Add(obj4delete);
                }

                using (var context = new Intern4jobEntities())
                {
                    var repository = new ProfessionRepository(context);
                    repository.BulkDelete(list4delete);
                    context.SaveChanges();
                    msg = string.Format(Intern4jobResources.MSG_BULK_ACTION_SUCCESS, Intern4jobResources.STR_DELETE, idArr.Length);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(Intern4jobResources.MSG_BULK_ACTION_FAIL, Intern4jobResources.STR_DELETE, idArr.Length) + string.Format(Intern4jobResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg, e);
            }
        }
Ejemplo n.º 3
0
        public static int CountUserByQuery(UserQuery query)
        {
            using (var context = new Intern4jobEntities())
            {
                var repository = new UserRepository(context);

                int count = repository.GetPageCount(item => _isMatch(item, query));
                return count;
            }
        }
        public static BaseActionResult DeleteProfession(Profession obj4delete)
        {
            using (var context = new Intern4jobEntities())
            {
                string msg;
                var repository = new ProfessionRepository(context);

                if (obj4delete == null)
                {
                    msg = string.Format(Intern4jobResources.MSG_DELETE_SUCCESS, Intern4jobResources.STR_PROFESSION) + string.Format(Intern4jobResources.STR_FAIL_RESAON, Intern4jobResources.MSG_OBJECT_IS_NULL);
                    return new BaseActionResult(false, msg);
                }
                repository.Delete(obj4delete);
                context.SaveChanges();
                msg = string.Format(Intern4jobResources.MSG_UPDATE_SUCCESS, obj4delete.Name);
                return new BaseActionResult(true, msg);
            }
        }
        public static List<Profession> GetProfessionListByQuery(ProfessionQuery query)
        {
            using (var context = new Intern4jobEntities())
            {
                var repository = new ProfessionRepository(context);

                List<Profession> professions = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return professions;
            }
        }
Ejemplo n.º 6
0
        public static BaseActionResult UpdateUser(User obj4update)
        {
            string msg;
            if (obj4update == null)
            {
                msg = string.Format(Intern4jobResources.MSG_UPDATE_SUCCESS, Intern4jobResources.STR_USER) + string.Format(Intern4jobResources.STR_FAIL_RESAON, Intern4jobResources.MSG_OBJECT_IS_NULL);
                return new BaseActionResult(false, msg);
            }

            try
            {
                using (var context = new Intern4jobEntities())
                {
                    var repository = new UserRepository(context);
                    repository.Update(obj4update);
                    context.SaveChanges();
                    msg = string.Format(Intern4jobResources.MSG_UPDATE_SUCCESS, obj4update.Name);
                    return new BaseActionResult(true, msg);
                }
            }
            catch (Exception e)
            {
                msg = string.Format(Intern4jobResources.MSG_UPDATE_FAIL, obj4update.Name) + string.Format(Intern4jobResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
                return new BaseActionResult(false, msg);
            }
        }
Ejemplo n.º 7
0
        public static List<User> GetUserListByQuery(UserQuery query)
        {
            using (var context = new Intern4jobEntities())
            {
                var repository = new UserRepository(context);

                List<User> users = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return users;
            }
        }