예제 #1
0
        public ServiceResult <object> Save(BusinessParam bp, PersonDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                DataLayer.Model.Core.Person.Person person;
                if (dto.EntityId == 0)
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        person = Copier.GetEntity(dto, bp, true);
                        unitOfWork.Person.Insert(person);
                        unitOfWork.Person.Save();
                    }
                }
                else
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        person = Copier.GetEntity(dto, bp, false);
                        unitOfWork.Person.Update(person);
                        unitOfWork.Person.Save();
                    }
                }

                Elastic <PersonDto, DataLayer.Model.Core.Person.Person> .SaveToElastic(person, ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(Copier.GetDto(person), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
        public ServiceResult <object> DeletedList(BusinessParam bp, long roleId)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    var accessGroups = unitOfWork.RoleAccessGroup.Get(p => p.Role == roleId).ToList();
                    foreach (var item in accessGroups)
                    {
                        unitOfWork.RoleAccessGroup.Delete(item);
                        Elastic <RoleAccessGroupDto, DataLayer.Model.Core.RoleAccessGroup.RoleAccessGroup> .SaveToElastic(
                            item, ClassDetails[0].Clazz, bp);
                    }

                    unitOfWork.UseCaseActionAccessGroup.Save();
                }

                return(new ServiceResult <object>(true, 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #3
0
        public ServiceResult <object> Delete(BusinessParam bp)
        {
            var  methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";
            long entityId   = 0;

            foreach (var where in bp.Clause.Wheres.Where(where =>
                                                         where.Key.Equals("entityId") && where.Value != null && !where.Value.Equals("")))
            {
                entityId = long.Parse(where.Value);
            }

            try
            {
                if (entityId == 0)
                {
                    return(ExceptionUtil.ExceptionHandler("شناسه مورد نظر یافت نشد",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                DataLayer.Model.Core.UseCase.UseCase useCase;
                using (var unitOfWork = new UnitOfWork())
                {
                    useCase = unitOfWork.UseCase.GetRecord(entityId);
                }

                if (useCase == null)
                {
                    return(ExceptionUtil.ExceptionHandler("شناسه مورد نظر یافت نشد",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }

                useCase.Deleted = useCase.EntityId;
                using (var unitOfWork = new UnitOfWork())
                {
                    unitOfWork.UseCase.Update(useCase);
                    unitOfWork.UseCase.Save();
                }

                Elastic <UseCaseDto, DataLayer.Model.Core.UseCase.UseCase> .SaveToElastic(useCase, ClassDetails[0].Clazz,
                                                                                          bp);

                return(new ServiceResult <object>(true, 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #4
0
        private async Task <ServiceResult <object> > CreateThumbnail(IFormFile formFile, FileDto fileDto, BusinessParam bp)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                var webRootPath = bp.Environment.WebRootPath;
                var dto         = new FileDto
                {
                    Alt                  = fileDto.Alt,
                    DataSize             = fileDto.DataSize,
                    Description          = fileDto.Description,
                    DisplayInFileManager = false,
                    Extension            = fileDto.Extension,
                    FullTitle            = fileDto.FullTitle,
                    Name                 = fileDto.Name,
                    ParentId             = fileDto.ParentId,
                    Path                 = fileDto.Path,
                    Thumbnail            = fileDto.Thumbnail,
                    Title                = fileDto.Title
                };
                var resize = new ImageResize();
                resize.Resize(webRootPath + dto.Path, webRootPath + dto.Thumbnail);
                dto.DisplayInFileManager = false;
                dto.Path = dto.Thumbnail;
                var file = Copier.GetEntity(dto, bp, true);
                using (var unitOfWork = new UnitOfWork())
                {
                    var done = unitOfWork.File.Insert(file);
                    unitOfWork.File.Save();
                    if (!done)
                    {
                        return(ExceptionUtil.ExceptionHandler("خطا در ذخیره فایل درون دیتابیس",
                                                              ClassDetails[0].Facade + methodName,
                                                              bp.UserInfo));
                    }
                    Elastic <FileDto, DataLayer.Model.Core.File.File> .SaveToElastic(file, ClassDetails[0].Clazz, bp);

                    dto.EntityId = file.EntityId;
                    return(new ServiceResult <object>(dto, 1));
                }
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #5
0
        public ServiceResult <object> SaveList(BusinessParam bp, List <UseCaseActionAccessGroupDto> lstDto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                foreach (var dto in lstDto)
                {
                    DataLayer.Model.Core.UseCaseActionAccessGroup.UseCaseActionAccessGroup caseActionAccessGroup;
                    if (dto.EntityId == 0)
                    {
                        using (var unitOfWork = new UnitOfWork())
                        {
                            caseActionAccessGroup = Copier.GetEntity(dto, bp, true);
                            if (caseActionAccessGroup.UseCaseAction != -1)
                            {
                                unitOfWork.UseCaseActionAccessGroup.Insert(caseActionAccessGroup);
                                unitOfWork.UseCaseActionAccessGroup.Save();
                            }
                        }
                    }
                    else
                    {
                        using (var unitOfWork = new UnitOfWork())
                        {
                            caseActionAccessGroup = Copier.GetEntity(dto, bp, false);
                            unitOfWork.UseCaseActionAccessGroup.Update(caseActionAccessGroup);
                            unitOfWork.UseCaseActionAccessGroup.Save();
                        }
                    }

                    Elastic <UseCaseActionAccessGroupDto,
                             DataLayer.Model.Core.UseCaseActionAccessGroup.UseCaseActionAccessGroup>
                    .SaveToElastic(caseActionAccessGroup, "UseCaseActionAccessGroup", bp);
                }

                return(new ServiceResult <object>(true, 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #6
0
        public ServiceResult <object> Save(BusinessParam bp, BusinessAccessDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                DataLayer.Model.Core.BusinessAccess.BusinessAccess businessAccess;

                dto = AddList(bp, dto);

                if (dto.EntityId == 0)
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        businessAccess = Copier.GetEntity(dto, bp, true);
                        unitOfWork.BusinessAccess.Insert(businessAccess);
                        unitOfWork.BusinessAccess.Save();
                    }
                }
                else
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        businessAccess = Copier.GetEntity(dto, bp, false);
                        unitOfWork.BusinessAccess.Update(businessAccess);
                        unitOfWork.BusinessAccess.Save();
                    }
                }

                Elastic <BusinessAccessDto, DataLayer.Model.Core.BusinessAccess.BusinessAccess> .SaveToElastic(
                    businessAccess, ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(Copier.GetDto(businessAccess), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #7
0
        public ServiceResult <object> Delete(BusinessParam bp, EntityStateDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                DataLayer.Model.Core.EntityState.EntityState entityState;
                using (var unitOfWork = new UnitOfWork())
                {
                    entityState = unitOfWork.EntityState
                                  .Get(p => p.TableEntityId == dto.TableEntityId && p.TableName == dto.TableName)
                                  .FirstOrDefault();
                }

                if (entityState == null)
                {
                    return(ExceptionUtil.ExceptionHandler("شناسه مورد نظر یافت نشد",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                using (var unitOfWork = new UnitOfWork())
                {
                    unitOfWork.EntityState.Delete(entityState);
                    unitOfWork.EntityState.Save();
                }

                Elastic <EntityStateDto, DataLayer.Model.Core.EntityState.EntityState> .SaveToElastic(entityState,
                                                                                                      ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(true, 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #8
0
        public ServiceResult <object> Save(BusinessParam bp, UserDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                Users users;
                if (dto.EntityId == 0)
                {
                    var checkUserExist = CheckUserExist(bp, dto.Username);
                    if (!checkUserExist.Done)
                    {
                        return(checkUserExist);
                    }

                    if (checkUserExist.Done && checkUserExist.ResultCountAll == 1)
                    {
                        return(new ServiceResult <object>(Enumerator.ErrorCode.ApplicationError,
                                                          "کاربر گرامی با عرض پوزش این نام کاربری از قبل موجود می باشد"));
                    }

                    dto.Password = GetHashPassword(dto.Password);
                    using (var unitOfWork = new UnitOfWork())
                    {
                        users = Copier.GetEntity(dto, bp, true);
                        unitOfWork.Users.Insert(users);
                        unitOfWork.Users.Save();
                    }
                }
                else
                {
                    var checkUserExist = CheckUserExist(bp, dto.Username);
                    if (!checkUserExist.Done)
                    {
                        return(checkUserExist);
                    }

                    if (checkUserExist.Done && checkUserExist.ResultCountAll == 1)
                    {
                        var result = (Users)checkUserExist.Result;
                        if (result.EntityId != dto.EntityId)
                        {
                            return(new ServiceResult <object>(Enumerator.ErrorCode.ApplicationError,
                                                              "کاربر گرامی با عرض پوزش این نام کاربری از قبل موجود می باشد"));
                        }

                        if (result.Password != dto.Password)
                        {
                            dto.Password = GetHashPassword(dto.Password);
                        }
                        using (var unitOfWork = new UnitOfWork())
                        {
                            users = Copier.GetEntity(dto, bp, false);
                            unitOfWork.Users.Update(users);
                            unitOfWork.Users.Save();
                        }
                    }
                    else
                    {
                        dto.Password = GetHashPassword(dto.Password);
                        using (var unitOfWork = new UnitOfWork())
                        {
                            users = Copier.GetEntity(dto, bp, false);
                            unitOfWork.Users.Update(users);
                            unitOfWork.Users.Save();
                        }
                    }
                }

                Elastic <UserDto, Users> .SaveToElastic(users, ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(Copier.GetDto(users), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #9
0
        public ServiceResult <object> Save(BusinessParam bp, UseCaseDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                if (dto.Parent == null)
                {
                    dto.Parent = new UseCaseDto {
                        EntityId = 1
                    }
                }
                ;
                var useCase = new DataLayer.Model.Core.UseCase.UseCase();
                if (dto.EntityId == 0)
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        useCase = Copier.GetEntity(dto, bp, true);
                        unitOfWork.UseCase.Insert(useCase);
                        unitOfWork.UseCase.Save();
                    }

                    if (dto.UseCaseActions != null)
                    {
                        foreach (var item in dto.UseCaseActions)
                        {
                            item.UseCase = new UseCaseDto {
                                EntityId = useCase.EntityId
                            }
                        }
                        ;
                        var serviceResult = UseCaseActionFacade.GetInstance().SaveList(bp, dto.UseCaseActions);
                        if (!serviceResult.Done)
                        {
                            return(serviceResult);
                        }
                    }
                }
                else
                {
                    var deletedList = UseCaseActionFacade.GetInstance().DeletedList(bp, dto.EntityId);
                    if (deletedList.Done)
                    {
                        if (dto.UseCaseActions != null)
                        {
                            foreach (var item in dto.UseCaseActions)
                            {
                                item.UseCase = new UseCaseDto {
                                    EntityId = dto.EntityId
                                }
                            }
                            ;
                            var serviceResult = UseCaseActionFacade.GetInstance().SaveList(bp, dto.UseCaseActions);
                            if (serviceResult.Done)
                            {
                                using (var unitOfWork = new UnitOfWork())
                                {
                                    useCase = Copier.GetEntity(dto, bp, false);
                                    unitOfWork.UseCase.Update(useCase);
                                    unitOfWork.UseCase.Save();
                                }
                            }
                            else
                            {
                                return(serviceResult);
                            }
                        }
                    }
                    else
                    {
                        return(deletedList);
                    }
                }

                Elastic <UseCaseDto, DataLayer.Model.Core.UseCase.UseCase> .SaveToElastic(useCase, ClassDetails[0].Clazz,
                                                                                          bp);

                return(new ServiceResult <object>(Copier.GetDto(useCase), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #10
0
        public async Task <ServiceResult <object> > CreateFile(BusinessParam bp, HttpRequest request)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                if (string.IsNullOrEmpty(request.Form["name"]))
                {
                    return(ExceptionUtil.ExceptionHandler("لطفا نام فایل را وارد نمایید",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                if (request.Form.Files["file"] == null)
                {
                    return(ExceptionUtil.ExceptionHandler("لطفا فایل را انتخاب نمایید",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }


                long?parentId    = null;
                var  webRootPath = bp.Environment.WebRootPath;
                var  fileName    = "\\file\\" + DateTime.UtcNow.RepositoryFolderName();
                if (!string.IsNullOrEmpty(request.Form["path"]))
                {
                    parentId = long.Parse(request.Form["parentId"]);
                    fileName = request.Form["path"] + DateTime.UtcNow.RepositoryFolderName();
                }

                var formFile = request.Form.Files["file"];
                if (formFile.Length <= 0)
                {
                    return(ExceptionUtil.ExceptionHandler("فایل ارسالی خالی می باشد",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                var extension = formFile.FileName.Split(".")[1];
                var exists    = System.IO.File.Exists(webRootPath + fileName + "." + extension);
                if (exists)
                {
                    return(ExceptionUtil.ExceptionHandler("فایل تکراری می باشد", ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                var checkFileIsValid = CheckFileIsValid(formFile, extension);
                if (!checkFileIsValid.Done)
                {
                    return(checkFileIsValid);
                }
                using (var inputStream = new FileStream(webRootPath + fileName + "." + extension, FileMode.Create))
                {
                    await formFile.CopyToAsync(inputStream);

                    var array = new byte[inputStream.Length];
                    inputStream.Seek(0, SeekOrigin.Begin);
                    inputStream.Read(array, 0, array.Length);
                }

                var fileDto = new FileDto
                {
                    Alt                  = request.Form["alt"],
                    DataSize             = formFile.Length.ToString(),
                    Description          = request.Form["description"],
                    DisplayInFileManager = true,
                    Extension            = extension.ToLower(),
                    FullTitle            =
                        request.Form["name"] + " | " + request.Form["description"] + " | " + request.Form["alt"],
                    Name      = request.Form["name"],
                    ParentId  = parentId,
                    Path      = fileName + "." + extension,
                    Thumbnail = fileName + "_thumb." + extension,
                    Title     = formFile.FileName
                };
                if (formFile.IsImage())
                {
                    var thumbnail = CreateThumbnail(formFile, fileDto, bp);
                }

                var file = Copier.GetEntity(fileDto, bp, true);
                using (var unitOfWork = new UnitOfWork())
                {
                    var done = unitOfWork.File.Insert(file);
                    unitOfWork.File.Save();
                    if (!done)
                    {
                        return(ExceptionUtil.ExceptionHandler("خطا در ذخیره فایل درون دیتابیس",
                                                              ClassDetails[0].Facade + methodName,
                                                              bp.UserInfo));
                    }
                    Elastic <FileDto, DataLayer.Model.Core.File.File> .SaveToElastic(file, ClassDetails[0].Clazz, bp);

                    fileDto.EntityId = file.EntityId;
                    return(new ServiceResult <object>(fileDto, 1));
                }
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #11
0
        public ServiceResult <object> CreateFolder(BusinessParam bp, FolderDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                if (string.IsNullOrEmpty(dto.FolderName))
                {
                    return(ExceptionUtil.ExceptionHandler("لطفا نام پوشه را وارد نمایید",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                long?parentId    = null;
                var  webRootPath = bp.Environment.WebRootPath;
                var  fileName    = "\\file\\" + DateTime.UtcNow.RepositoryFolderName();
                if (!string.IsNullOrEmpty(dto.Path))
                {
                    parentId = dto.ParentId;
                    fileName = dto.Path + DateTime.UtcNow.RepositoryFolderName();
                }

                var exists = Directory.Exists(webRootPath + fileName);
                if (exists)
                {
                    return(ExceptionUtil.ExceptionHandler("نام پوشه تکراری می باشد",
                                                          ClassDetails[0].Facade + methodName,
                                                          bp.UserInfo));
                }
                Directory.CreateDirectory(webRootPath + fileName);
                var fileDto = new FileDto
                {
                    Alt                  = "",
                    DataSize             = "0",
                    Description          = "",
                    DisplayInFileManager = true,
                    Extension            = null,
                    FullTitle            = fileName + " | " + dto.FolderName,
                    Name                 = dto.FolderName,
                    ParentId             = parentId,
                    Path                 = fileName + "\\",
                    Thumbnail            = fileName + "\\",
                    Title                = dto.FolderName
                };
                var file = Copier.GetEntity(fileDto, bp, true);
                using (var unitOfWork = new UnitOfWork())
                {
                    var done = unitOfWork.File.Insert(file);
                    unitOfWork.File.Save();
                    if (!done)
                    {
                        return(ExceptionUtil.ExceptionHandler("خطا در ذخیره فایل درون دیتابیس",
                                                              ClassDetails[0].Facade + methodName,
                                                              bp.UserInfo));
                    }
                    Elastic <FileDto, DataLayer.Model.Core.File.File> .SaveToElastic(file, ClassDetails[0].Clazz, bp);

                    fileDto.EntityId = file.EntityId;
                    return(new ServiceResult <object>(fileDto, 1));
                }
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #12
0
        public ServiceResult <object> Save(BusinessParam bp, List <UseCaseActionAccessGroupDto> dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                DataLayer.Model.Core.AccessGroup.AccessGroup accessGroup;
                if (dto[0].AccessGroup.EntityId == 0)
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        accessGroup = Copier.GetEntity(dto[0].AccessGroup, bp, true);
                        unitOfWork.AccessGroup.Insert(accessGroup);
                        unitOfWork.AccessGroup.Save();
                    }

                    foreach (var item in dto)
                    {
                        item.AccessGroup = Copier.GetDto(accessGroup);
                    }
                    var serviceResult = UseCaseActionAccessGroupFacade.GetInstance().SaveList(bp, dto);
                    if (!serviceResult.Done)
                    {
                        return(serviceResult);
                    }
                }
                else
                {
                    var delete = UseCaseActionAccessGroupFacade.GetInstance()
                                 .DeletedList(bp, dto[0].AccessGroup.EntityId);
                    if (delete.Done)
                    {
                        using (var unitOfWork = new UnitOfWork())
                        {
                            accessGroup = Copier.GetEntity(dto[0].AccessGroup, bp, false);
                            unitOfWork.AccessGroup.Update(accessGroup);
                            unitOfWork.AccessGroup.Save();
                        }

                        foreach (var item in dto)
                        {
                            item.AccessGroup = Copier.GetDto(accessGroup);
                        }
                        var serviceResult = UseCaseActionAccessGroupFacade.GetInstance().SaveList(bp, dto);
                        if (!serviceResult.Done)
                        {
                            return(serviceResult);
                        }
                    }
                    else
                    {
                        return(delete);
                    }
                }

                Elastic <AccessGroupDto, DataLayer.Model.Core.AccessGroup.AccessGroup> .SaveToElastic(accessGroup,
                                                                                                      ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(Copier.GetDto(accessGroup), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
예제 #13
0
        public ServiceResult <object> Save(BusinessParam bp, RoleDto dto)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                DataLayer.Model.Core.Role.Role role;
                if (dto.EntityId == 0)
                {
                    using (var unitOfWork = new UnitOfWork())
                    {
                        role = Copier.GetEntity(dto, bp, true);
                        unitOfWork.Role.Insert(role);
                        unitOfWork.Role.Save();
                    }

                    if (dto.AccessGroupDto != null)
                    {
                        var lstGroup = dto.AccessGroupDto.Select(item => new RoleAccessGroupDto
                        {
                            Role = Copier.GetDto(role), AccessGroup = item
                        }).ToList();
                        var serviceResult = RoleAccessGroupFacade.GetInstance().SaveList(bp, lstGroup);
                        if (!serviceResult.Done)
                        {
                            return(serviceResult);
                        }
                    }
                }

                else
                {
                    var deletedList = RoleAccessGroupFacade.GetInstance().DeletedList(bp, dto.EntityId);
                    if (deletedList.Done)
                    {
                        using (var unitOfWork = new UnitOfWork())
                        {
                            role = Copier.GetEntity(dto, bp, false);
                            unitOfWork.Role.Update(role);
                            unitOfWork.Role.Save();
                        }

                        if (dto.AccessGroupDto != null)
                        {
                            var lstGroup = dto.AccessGroupDto.Select(item => new RoleAccessGroupDto
                            {
                                Role = Copier.GetDto(role), AccessGroup = item
                            }).ToList();
                            var serviceResult = RoleAccessGroupFacade.GetInstance().SaveList(bp, lstGroup);
                            if (!serviceResult.Done)
                            {
                                return(serviceResult);
                            }
                        }
                    }
                    else
                    {
                        return(deletedList);
                    }
                }

                Elastic <RoleDto, DataLayer.Model.Core.Role.Role> .SaveToElastic(role, ClassDetails[0].Clazz, bp);

                return(new ServiceResult <object>(Copier.GetDto(role), 1));
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }