public DataLayer.Model.Core.UseCaseActionAccessGroup.UseCaseActionAccessGroup GetEntity(
            UseCaseActionAccessGroupDto dto, BusinessParam bp, bool setCreate)
        {
            var useCaseActionAccessGroup = new DataLayer.Model.Core.UseCaseActionAccessGroup.UseCaseActionAccessGroup
            {
                EntityId  = dto.EntityId,
                Active    = dto.Active,
                Code      = dto.Code,
                Deleted   = dto.Deleted,
                FullTitle = dto.AccessGroup?.EntityId + " | " + dto.UseCaseAction?.EntityId + " | " + dto.Code + " | " +
                            dto.EntityId,
                AccessGroup   = dto.AccessGroup.EntityId,
                UseCaseAction = UseCaseActionFacade.GetInstance().GetUseCaseAction(dto.UseCaseAction)
            };

            return(SetMandatoryField(useCaseActionAccessGroup, bp, setCreate));
        }
Esempio n. 2
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));
            }
        }